Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

K = int(input())
a1 = 7
ai = 0
for i in range(K + 1):
  ai = a1 % K
  a1 = (a1 * 10 + 7)
  if ai == 0:
    break
else:
  i = -2 
print(i + 1)

### FIXED CODE ###

K = int(input())
a1 = 7
ai = 0
for i in range(K + 1):
  if i == 0:
    ai = a1 % K
  else:
    ai = (ai * 10 + 7) % K
  if ai == 0:
    break
else:
    i = -2
print(i + 1)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))

from itertools import combinations

for k in range(N):
  S = A[:k]+A[k+1:]
  ans = 0
  for c in combinations(S,2):
    if c[0]==c[1]:
      ans +=1
  print(ans)

### FIXED CODE ###

import math
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

def comb2(n):
    return n * (n - 1) // 2

c = Counter(A)
ans = 0
for m in c.values():
    if m >= 2:
        ans +=comb2(m)

for i in range(N):
    print(ans - c[A[i]] + 1)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

# dp[i][j] := Sの後ろからi桁を13で割った余りがjとなるようなものの個数
def main():
    S = input()
    l = len(S)
    dp = [[0]*(13) for _ in range(10**5+10)]
    dp[0][0] = 1
    mul = 1  
    for i in range(l):
        x = S[-(i+1)]
        if x == "?":
            for k in range(10):
                for j in range(13):
                    dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                    dp[i + 1][(mul * k + j) % 13] %= MOD
        else:
            k = int(x) # これしか選ぶ余地なし
            for j in range(13):
                dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                dp[i + 1][(mul * k + j) % 13] %= MOD
        mul *= 10 % 13
    print(dp[l][5]%MOD)


if __name__ == "__main__":
    main()


### FIXED CODE ###

INF = 10 ** 9 + 7

S = input()
# dp[i][j]はうしろからi桁を13で割った余りがjであるものの個数
dp = [[0] * 13 for _ in range(len(S) + 1)]
dp[0][0] = 1
mul = 1

for i in range(len(S)):
    x = S[-(i + 1)]
    if x == "?":
        for k in range(10):
            for j in range(13):
                dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                dp[i + 1][(mul * k + j) % 13] %= INF
    else:
        k = int(x)
        for j in range(13):
            dp[i + 1][(mul * k + j) % 13] += dp[i][j]
            dp[i + 1][(mul * k + j) % 13] %= INF
    mul = mul * 10 % 13  # 計算量削減のためここで13で割っている

print(dp[len(S)][5])
### BUGGY CODE ###

N = int(input())
Num = list(map(int,input().split()))
ki = []
count = 0
for i in range(N):
    if Num[i] in ki:
        pass
    else:
        c = Num.count(Num[i])
        if c > Num[i]:
            count+=(c-Num[i])
        elif c < Num[i]:
            count+=c
        else:
            pass
        ki.append(Num[i])
print(count)

### FIXED CODE ###

N = int(input())
Num = list(map(int,input().split()))
ki = []
count = 0
for i in range(N):
    if Num[i] in ki:
        pass
    elif Num[i] > 100000:
        count+=1
    else:
        c = Num.count(Num[i])
        if c > Num[i]:
            count+=(c-Num[i])
        elif c < Num[i]:
            count+=c
        else:
            pass
        ki.append(Num[i])
print(count)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
B = list(map(int, input().split()))
B.sort(reverse=True)
C = list(map(int, input().split()))
C.sort(reverse=True)

Bn = [0] * N
prea = 0
for b in range(N):
    for a in range(prea, N):
        if A[a] < B[b]:
            prea = a
            break
    else:
        break
    Bn[b] = N-a

ans = 0
preb = 0
for c in range(N):
    for b in range(preb, N):
        if B[b] < C[c]:
            preb = b
            break
    else:
        break
    ans += sum(Bn[b:])

print(ans)


### FIXED CODE ###

import bisect
N = int(input())
A = list(map(int, input().split()))
A.sort()
B = list(map(int, input().split()))
C = list(map(int, input().split()))
C.sort()

ans = 0
for i in range(N):
    cnta = bisect.bisect_left(A, B[i])
    cntc = bisect.bisect_right(C, B[i])
    ans += cnta * (N - cntc)

print(ans)
### BUGGY CODE ###

import sys
import numpy as np
from scipy.sparse.csgraph import bellman_ford, connected_components
from scipy.sparse import csr_matrix
input = sys.stdin.readline


def main():
    n, m, p = map(int, input().split())
    
    inf = 10**9
    l = np.zeros((n, n))
    tree_forth = [[] for _ in range(n)]
    tree_back = [[] for _ in range(n)]
    for i in range(m):
        a, b, c =map(int, input().split())
        tree_forth[a-1].append(b-1)
        tree_back[b-1].append(a-1)
        c = p-c
        if c == 0:
            c = 10**(-7.9)
        if l[a-1][b-1] == 0:
            l[a-1][b-1] = c
        else:
            l[a-1][b-1] = min(l[a-1][b-1], c)
    x = l[-1, 0]
    l[-1][0] = 10**(-7.9)
    n, labels = connected_components(l, connection="strong")
    l = l[labels == labels[0]][:, labels == labels[0]]
    l[-1, 0] = x
    
    try:
        print(max(0, int(bellman_ford(csr_matrix(l))[0][-1])*(-1)))
    except:
        print(-1)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
import numpy as np
from scipy.sparse.csgraph import bellman_ford, connected_components
input = sys.stdin.readline


def main():
    n, m, p = map(int, input().split())
    
    l = np.zeros((n, n))
    for i in range(m):
        a, b, c =map(int, input().split())
        c = p-c
        if c == 0:
            c = 10**(-7.9)
        if l[a-1][b-1] == 0:
            l[a-1][b-1] = c
        else:
            l[a-1][b-1] = min(l[a-1][b-1], c)
    x = l[-1, 0]
    l[-1][0] = 10**(-7.9)
    n, labels = connected_components(l, connection="strong")
    l = l[labels == labels[0]][:, labels == labels[0]]
    l[-1, 0] = x
    
    try:
        print(max(0, int(round(bellman_ford(l, indices=0)[-1]))*(-1)))
    except:
        print(-1)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

n = int(input())
l = list(map(int, input().split()))

x = "YES"
k = 0
for i in l:
  k += 1
  for j in l[k:]:
    if i == j:
      x = "NO"
      break

print(x)

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))

A = len(l)
B = len(set(l))
if A == B:
  print("YES")
else:
  print("NO")
### BUGGY CODE ###

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr
X = int(input())
A = []
for i in factorization(X):
  for j in range(0,i[1]+1):
    a = i[0]**j
    b = X//a
    if(a<b):
      A.append([a,b])
    else:
      A.append([b,a])
 
A = list(map(list, set(map(tuple, A))))
flag = 0
for i in A:
  r = list(range(0,1000000+1))
  for a in r:
    b = a - i[0]
    if a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4 == i[1]:
      print(a,b)
      flag = 1
      break
  if flag==1:
    break

### FIXED CODE ###


X = int(input())
flag = 0
for i in range(-150,150):
  for j in range(-150,150):
    if(i**5 - j**5 == X):
      print(i,j)
      flag = 1
      break
  if(flag==1):
    break
### BUGGY CODE ###

n = int(input())
ans = 0
for i in range(1,n):
  for j in range(1,n):
    if i*j < n:
      ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
ans = 0
for i in range(1,n):
  if n%i == 0:
    ans += int(n/i)-1
  else:
    ans += int(n/i)
print(ans)
### BUGGY CODE ###

N = int(input())
print(0)
s = str(input())
if s=='Vacant':
    exit()
temp = s

def is_ok():
    if temp == s and abs(mid-ng) % 2 == 1:
        return True
    elif temp != s and abs(mid-ok) % 2 == 0:
        return False


def bin_search_meguru():
    """
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng, okは,とり得る最小の値-1,とり得る最大の値+1
    """
    global ng
    global ok
    global mid

    # 適当にいじる
    ng = 0  
    ok = N-1  # ind=len(a)-1が条件を満たさないこともあるため
    # いじらない
    # okとngのどちらが大きいかわからないことを考慮
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        print(mid)
        s = str(input())
        if is_ok():
            ok = mid
            temp=s
        else:
            ng = mid
            temp=s

bin_search_meguru()


### FIXED CODE ###

N = int(input())


def query(i):
    print(i)
    s = input()
    if s == 'Vacant':
        exit()
    return s


root = query(0)


def is_ok(ind):
    # 左ならTrue
    response = query(ind)
    if ind % 2 == 1:
        return root == response
    else:
        return root != response


def bin_search_meguru():
    """
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng, okは,とり得る最小の値-1,とり得る最大の値+1
    """

    # 適当にいじる
    ng = -1  # ind=0が条件を満たすこともあるため
    ok = N  # ind=len(a)-1が条件を満たさないこともあるため

    # いじらない
    # okとngのどちらが大きいかわからないことを考慮
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return False


bin_search_meguru()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]
N , Q = map(int,input().split())
graph = [[] for _ in range(N)]
point = [0] * N
for _ in range(N - 1):
    a , b = map(int,input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)

for _ in range(Q):
    a , b = map(int,input().split())
    a = a - 1
    point[a] += b

def dfs(now , prev = -1):
    for next in graph[now]:
        if next == prev:
            continue
        point[next] += point[now]
        dfs(next , now)

dfs(0)
print(*point)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]
N , Q = map(int,input().split())
graph = [[] for _ in range(N)]
point = [0] * N
for _ in range(N - 1):
    a , b = map(int,input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)

for _ in range(Q):
    a , b = map(int,input().split())
    a = a - 1
    point[a] += b

def dfs(now , prev = -1):
    for next in graph[now]:
        if next == prev:
            continue
        point[next] += point[now]
        dfs(next , now)

dfs(0)
print(*point)
### BUGGY CODE ###

import bisect
n,m = map(int,input().split())
A = list(map(int,input().split()))
for _ in range(m):
    A.sort()
    b,c = map(int,input().split())
    index = bisect.bisect_right(A,c)
    if index == 0:
        pass
    elif b >= index:
        for i in range(0,index):
            A[i] = c
    else:
        for i in range(b):
            A[i] = c
print(sum(A))

### FIXED CODE ###

import sys
input = sys.stdin.readline
import bisect
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

minA = A[0]
Query = []
for _ in range(m):
    b,c = map(int,input().split())
    if c > minA:
        Query.append([b,c])
Query = sorted(Query, key=lambda x:(x[1], x[0]), reverse=True)

ans = 0
index = 0
for b,c in Query:
    if index >= n:
        break
    #print("----")
    cnt = 0
    Flag = True
    while Flag:
        #print(A,b,c,index)
        if A[index] < c:
            A[index] = c
            cnt += 1
            index += 1
            if (cnt >= b) or (index >= n):
                Flag = False
        else:
            Flag = False
    '''
    #A.sort()
    if A[0] >= c:
        break
    else:
        index = min(bisect.bisect_left(A,c),b)
        if index > len(A):
            ans += c * len(A)
            break
        else:
            ans += c * index
            A = A[index:]
    print(A)
    '''
print(sum(A))
### BUGGY CODE ###

import sys
import math
from collections import defaultdict
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()
def make_grid_int(h, w, num): return [[int(num)] * w for _ in range(h)]
def main():
    R, C, K = NMI()
    grid = make_grid_int(R, C, 0)

    for i in range(K):
        r_, c_, v_, = NMI()
        grid[r_ - 1][c_ - 1] = v_

    dp = [[[0 for _ in range(4)] for _ in range(C + 2)] for _ in range(R + 2)]

    for i in range(R + 1):
        for j in range(C + 1):
            for k in range(4):
                try:
                    v = grid[i][j]
                except:
                    v = 0

                if k == 3:
                    dp[i + 1][j][0] = max(dp[i][j][k], dp[i + 1][j][0])
                    continue
                dp[i + 1][j][0] = max(dp[i][j][k], dp[i][j][k] + v, dp[i + 1][j][0])
                dp[i][j + 1][k] = max(dp[i][j][k], dp[i][j + 1][k])
                dp[i][j + 1][k + 1] = max(dp[i][j][k] + v, dp[i][j + 1][k + 1])

    print(max(dp[R][C][0], dp[R][C][1], dp[R][C][2], dp[R][C][3]))

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
import math
from collections import defaultdict
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid_int(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    R, C, K = NMI()
    grid = make_grid_int(R, C, 0)
    for i in range(K):
        r, c, v = NMI()
        grid[r-1][c-1] = v

    dp = [[[0 for _ in range(C+2)] for _ in range(R+2)] for _ in range(4)]

    for r in range(R+1):
        for c in range(C+1):
            for i in range(4):
                now = dp[i][r][c]
                try:
                    val = grid[r][c]
                except:
                    val = 0

                if i == 3:
                    # 取らずに下
                    dp[0][r + 1][c] = max(now, dp[0][r + 1][c])
                    continue

                # 取って下
                dp[0][r+1][c] = max(now + val, dp[0][r+1][c])
                # 取らずに下
                dp[0][r+1][c] = max(now, dp[0][r+1][c])
                # 取って横
                dp[i+1][r][c+1] = max(now + val, dp[i+1][r][c+1])
                # 取らずに横
                dp[i][r][c+1] = max(now, dp[i][r][c+1])

    print(max(dp[0][R][C], dp[1][R][C], dp[2][R][C], dp[3][R][C]))


if __name__ == "__main__":
    main()
### BUGGY CODE ###

# -*- coding: utf-8 -*-
N = int(input())
A = input().split()

sum = 0
for i in range(N):
    count = 0
    for j in range(i+1, N):
        count += int(A[j])
    sum += int(A[i]) * count

print(sum % (10**9 + 7))


### FIXED CODE ###

# -*- coding: utf-8 -*-
N = int(input())
A = input().split()

B = [0]
for i in range(N):
    B.append(B[i] + int(A[i]))

sum = 0
for i in range(N):
    sum += int(A[i]) * (B[N] - B[i+1])

print(sum % (10**9 + 7))
### BUGGY CODE ###

def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    s = input()
    ope_num = 0
    index = 0
    a_stock = 0
    b_stock = 0
    s = list(s)
    while index < len(s):
        si = s[index]
        # print(index)
        # print(si)
        # print(a_stock)
        # print(b_stock)
        # print(ope_num)
        # print()
        if si == "A":
            if b_stock > 0:
                b_stock = 0
                a_stock = 1
            else:
                a_stock = 1
        elif si == "B" and a_stock > 0 and b_stock == 0:
            b_stock = 1
        elif si == "C" and a_stock > 0 and b_stock > 0:
            ope_num = ope_num + 1
            s[index - 2] = "B"
            s[index - 1] = "C"
            s[index] = "A"
            a_stock = 0
            b_stock = 0
            if index - 4 >= -1:
                index = index - 4
            else:
                index = index - 1
        else:
            a_stock = 0
            b_stock = 0
        index = index + 1
    print(ope_num)

# ABCの数
# ABCの前にあるAの分だけ追加で操作できる
# ABCの後にある(BC)の分だけ追加で操作できる

# Aがあれば覚えておく
# ABCと来たら、それより前側に隣接しているAの回数だけ追加で操作できる
# 見つかったABCをBCAに置き換える
# BCAのAから走査を継続する


### FIXED CODE ###

def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    s = input()
    ope_num = 0
    index = 0
    a_stock = 0
    b_stock = 0
    s = list(s)
    while index < len(s):
        # print(s)
        # print(index)
        # print(ope_num)
        # print()
        si = s[index]
        if si == "A":
            if b_stock > 0:
                a_stock = 1
            else:
                a_stock = a_stock + 1
            b_stock = 0
        elif a_stock > 0:
            if b_stock == 0:
                if si == "B":
                    b_stock = 1
                else:
                    a_stock = 0
                    b_stock = 0
            elif si == "C":
                ope_num = ope_num + a_stock
                # s[index - 2 - a_stock + 1] = "B"
                # s[index - 1 - a_stock + 1] = "C"
                # s[index] = "A"
                # index = index - 1
                a_stock = a_stock
                b_stock = 0
            else:
                a_stock = 0
                b_stock = 0
        else:
            a_stock = 0
            b_stock = 0
        index = index + 1
    print(ope_num)

# ABCの数
# ABCの前にあるAの分だけ追加で操作できる
# ABCの後にある(BC)の分だけ追加で操作できる

# Aがあれば覚えておく
# ABCと来たら、それより前側に隣接しているAの回数だけ追加で操作できる
# 見つかったABCをBCAに置き換える
# BCAのAから走査を継続する
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()
def prime_fact(m):
    pf={}
    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:pf[m]=1
    return pf

def main():
    n=int(input())
    A=list(map(int,input().split()))
    p_lis={}
    for a in A:
        p_a=prime_fact(a)
        for key in p_a:
            if not p_lis.get(key,False) or p_lis[key]<p_a[key]:
                p_lis[key]=p_a[key]
    k=1
    for key in p_lis:
        k*=key**p_lis[key]
    ans=0
    for a in A:
        ans=(ans+k//a)%(10**9+7)
    print(ans)

if __name__=='__main__':
    main()

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()
class Sieve: #区間[2,n]の値の素因数分解
    def __init__(self,n=1):
        self.primes=[]
        self.f=[0]*(n+1) #ふるい（素数ならその値）
        self.f[0]=self.f[1]=-1
        for i in range(2,n+1): #素数リスト作成
            if self.f[i]: continue
            self.primes.append(i)
            self.f[i]=i
            for j in range(i*i,n+1,i):
                if not self.f[j]:
                    self.f[j]=i  # 最小の素因数を代入
    def is_prime(self, x):
        return self.f[x]==x
    def prime_fact(self,x): # 素因数分解の昇順リスト, {2:p,3:q,5:r,...}
        fact_dict=dict()
        while x!=1:
            p=self.f[x]
            fact_dict[p]=fact_dict.get(p,0)+1
            x//=self.f[x]
        return fact_dict

def main():
    n=int(input())
    A=list(map(int,input().split()))
    mod=10**9+7
    p_lis={}
    Prime=Sieve(10**6+5)
    for a in A:
        f=Prime.prime_fact(a)
        #print(f)
        for key in f:
            p_lis[key]=max(p_lis.get(key,0),f[key])
    lcm=1
    #print(p_lis)
    for key in p_lis:
        lcm=(lcm*pow(key,p_lis[key],mod))%mod
    ans=0
    #print(lcm)
    for a in A:
        b=lcm*pow(a,mod-2,mod)%mod
        ans=(ans+b)%mod
    print(ans)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

# coding: utf-8
# Your code here!


N, W = map(int, input().split())

dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(1, N+1):
    w, v = map(int, input().split())
    for j in range(W+1):
        if j-w >= 0:
            dp[i][j] = max(dp[i-1][j-w]+v, dp[i][j])
        dp[i][j] = max(dp[i-1][j], dp[i][j])

# print(dp)
print(dp[N][W])

### FIXED CODE ###

def main():
    N, W = map(int, input().split())
 
    dp = [-1] * (W + 1)
    dp[0] = 0
    for _ in range(N):
        w, v = map(int, input().split())
        for i in range(W - w, -1, -1):
            if dp[i] == -1:
                continue
            if dp[i + w] < dp[i] + v:
                dp[i + w] = dp[i] + v
    print(max(dp))
 
 
main()
### BUGGY CODE ###

N = int(input())
ABC = [sorted(list(map(int,input().split()))) for i in range(3)]

ans = 0
for i in range(N):
  for j in range(N):
    if ABC[0][i]>=ABC[1][j]:
      continue
    else:
      for k in range(N):
        if ABC[1][j]>=ABC[2][k]:
          continue
        else:
          ans += 1
    
print(ans)

### FIXED CODE ###

import bisect
N = int(input())
ABC = [sorted(list(map(int,input().split()))) for i in range(3)]

ans = 0
for b in ABC[1]:
  ans += bisect.bisect_left(ABC[0],b)*(N-bisect.bisect_right(ABC[2],b))
print(ans)
### BUGGY CODE ###

import bisect
n=int(input())
l=sorted(list(map(int,input().split())))
#print(l)
ans=0
for a in range(n-2):
    for b in range(a+1,n-1):
        min_c= max(l[b]-l[a]+1,l[b+1])
        max_c= l[a]+l[b]-1
#        print(str(l[a])+","+str(l[b])+" "+str(min_c) + ":" + str(max_c))
        if(min_c <= max_c):
            ans+=bisect.bisect_right(l, max_c) - bisect.bisect_left(l, min_c)
print(ans)

### FIXED CODE ###

import bisect
n=int(input())
l=sorted(list(map(int,input().split())))
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        min_c=j+1
        max_c=bisect.bisect_left(l, l[j]+l[i])-1
        num=max_c-min_c+1
#        print(str(l[i])+" "+str(l[j])+":"+str(min_c)+" "+str(max_c)+":"+str(num))
        ans += num if num > 0 else 0
print(ans)
### BUGGY CODE ###

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

N, M = Is()
H = LI()
AB = [[0]*N for _ in range(N)]
for i in range(M):
    a, b = Is()
    a -= 1
    b -= 1
    AB[a][b] = H[b]
    AB[b][a] = H[a]

ans = 0
notgood = [False]*N

# print(AB)

for i in range(N):
    if max(AB[i]) < H[i]:
        ans += 1
    # if notgood[i]:
    #     continue
    # for j in range(N):
    #     if AB[i][j] != 0:
    #         if H[i] > H[j]:
    #             notgood[j] = True
    #         elif H[i] < H[j]:
    #             notgood[i] = True
    #             break
    #         else:
    #             notgood[i] = True
    #             notgood[j] = True
    #             break
    # else:
    #     ans += 1

print(ans)

### FIXED CODE ###

def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]


N, M = Is()
H = LI()
AB = [set() for _ in range(N)]
for i in range(M):
    a, b = Is()
    a -= 1
    b -= 1
    AB[a].add(b)
    AB[b].add(a)

ans = 0
notgood = [False]*N

# print(AB)

for i in range(N):
    # print("{} start".format(i))
    # print(AB[i])
    if notgood[i]:
        continue
    if len(AB[i]) == 0:
        ans += 1
        continue
    for x in AB[i]:
        # print(H[x], H[i])
        if H[x] > H[i]:
            notgood[i] = True
            break
        elif H[x] == H[i]:
            notgood[x] = True
            notgood[i] = True
            break
        else:
            notgood[x] = True
    else:
        ans += 1
        # print("{} is GOOD!!!".format(i))

print(ans)