Harryxun/stf_run huggingface dataset:
N = input()
n = [input() for i in range(N)]

def Is_prime(n):
    if n % 2 == 0:
        return False
    i = 3
    while i < int(n ** (0.5))+ 1:
        if n % i == 0:
            return False
    return True

count = 0
for j in n:
    if Is_prime(j):
        count += 1

print (count)

### FIXED CODE ###

N = int(input())
n = [int(input()) for i in range(N)]

def Is_prime(n):
    if n == 2:
        return True
    if n == 1:
        return False
    if n % 2 == 0:
        return False
    i = 3
    while i < int(n ** (0.5))+ 1:
        if n % i == 0:
            return False
        i += 2
    return True

count = 0
for j in n:
    if Is_prime(j):
        count += 1

print (count)
n, k = map(int,input().split())
print(sum(sorted(list(map(int,input().split())).reverse=True)[0:k]))

### FIXED CODE ###

n, k = map(int,input().split())
print(sum(sorted(list(map(int,input().split())),reverse=True)[0:k]))
X,A = int(input().split())
if X < A:
    print('0')
else:
    print('10')


### FIXED CODE ###

X,A = (input().split())
if X < A:
    print('0')
else:
    print('10')
import math

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

red = N-K + 1

#print(N, K, red)
cnt = 0
for i in range(1,K):
    ans = math.factorial(red) // (math.factorial(red - i) * math.factorial(i))*i
    w = 10**9+7
    print(ans%w)
    cnt+=ans

All =  math.factorial(N) // (math.factorial(N-K) * math.factorial(K))%(10**9+7)
print(All-cnt)

### FIXED CODE ###

import math

N, K = list(map(int, input().split()))
mod = 10**9+7


def combination(a, b):
    ans = (math.factorial(a) // math.factorial(a-b)) // math.factorial(b)
    return ans


for i in range(1, K+1):
    if (N-K+1-i) >= 0:
        ans1 = combination(N-K+1, i)
        ans2 = combination(K-1, i-1)
        print(ans1 % mod*ans2 % mod)
    else:
        print(0)
s = list(map(int, list(str(input()))))
k = int(input())
i = 0
while s[i] == 1:
  i += 1
if k <= i:
  print(1)
else:
  print(s[i])

### FIXED CODE ###

s = list(map(int, list(str(input()))))
k = int(input())
i = 0
if s.count(1) == len(s):
  print(1)
else:
  while s[i] == 1:
    i += 1
  if k <= i:
    print(1)
  else:
    print(s[i])
def main():
    a, b, c = map(int, input().split())
    k = int(input())

    op = 0
    while not (a < b and b < c):
        if not a < b:
            b *= 2
            op += 1
        elif not b < c:
            c *= 2
            op += 1

    if op <= k:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

### FIXED CODE ###

X = int(input())

if X <= 599:
    print(8)
elif X <= 799:
    print(7)
elif X <= 999:
    print(6)
elif X <= 1199:
    print(5)
elif X <= 1399:
    print(4)
elif X <= 1599:
    print(3)
elif X <= 1799:
    print(2)
elif X <= 1999:
    print(1)
M,D = map(int, input().split())

D = int(D)
ans = 0

for i in range(1,M+1):
    for j in range(1,D+1):
        if len(j) == 2:
            j1 = j // 10
            j2 = j % 10
            if j1 >= 2 and j2 >= 2 and j1 * j2 == i:
                ans += 1


print(ans)


### FIXED CODE ###

M,D = map(int, input().split())

D = int(D)
ans = 0

for i in range(1,M+1):
    for j in range(1,D+1):
        j = str(j)
        if len(j) == 2:
            j1 = int(j[0])
            j2 = int(j[1])
            if j1 >= 2 and j2 >= 2 and j1 * j2 == i:
                ans += 1


print(ans)
N, K, C = list(map(int, input().split()))
S = input()

work_day_min = []
work_day_max = []

for i in range(N):
    if S[i] == 'o':
        if i == 0 or i - work_day_min[-1] > C:
            work_day_min.append(i)
    if len(work_day_min) == K:
        break

for i in range(N):
    if S[N - i - 1] == 'o':
        if i == 0 or work_day_max[-1] - (N - i - 1) > C:
            work_day_max.append(N - i - 1)
    if len(work_day_max) == K:
        break

work_day_max.reverse()

for i in range(K):
    if work_day_min[i] == work_day_max[i]:
        print(work_day_min[i]+1)

### FIXED CODE ###

N, K, C = list(map(int, input().split()))
S = input()

work_day_min = []
work_day_max = []

for i in range(N):
    if S[i] == 'o':
        if i > 0 and len(work_day_min) > 0:
            if i - work_day_min[-1] <= C:
                continue
        work_day_min.append(i)
    if len(work_day_min) == K:
        break

for i in range(N):
    if S[N - i - 1] == 'o':
        if i > 0 and len(work_day_max) > 0:
            if work_day_max[-1] - (N - i - 1) <= C:
                continue
        work_day_max.append(N - i - 1)
    if len(work_day_max) == K:
        break

for i in range(K):
    if work_day_min[i] == work_day_max[K-i-1]:
        print(work_day_min[i]+1)
s, n = [int(i) for i in  raw_input().split()]
weights = []
values = []

for _ in range(n):
    w, v = [int(i) for i in raw_input().split()]
    weights.append(w)
    values.append(v)

def knapsack(weights, values, limit):
    n = len(weights)
    f = [[0 for _ in range(limit+1)] for _ in range(n)]

    if weights[0] <= limit:
        for w in range(weights[0], limit):
            f[0][w] = values[0]

    for w in range(1, limit+1):
        for i in range(1, n):
            f[i][w] = max(f[i-1][w], f[i][w])
            if weights[i] <= w:
                f[i][w] = max(f[i][w], f[i-1][w-weights[i]] + values[i])

    return f[-1][-1]

# weights = [10, 20, 30]
# values = [60, 100, 120]
print(knapsack(weights, values, s))

### FIXED CODE ###

n, s = [int(i) for i in  raw_input().split()]
weights = []
values = []

for _ in xrange(n):
    w, v = [int(i) for i in raw_input().split()]
    weights.append(w)
    values.append(v)

def knapsack(weights, values, limit):
    n = len(weights)
    # f = [[0 for _ in xrange(limit+1)] for _ in xrange(n)]

    prev = [0 for _ in xrange(limit+1)]

    if weights[0] <= limit:
        for w in xrange(weights[0], limit+1):
            prev[w] = values[0]

    for i in xrange(1, n):
        # print prev
        current = [0] * (limit+1)
        for w in xrange(1, limit+1):
            current[w] = max(prev[w], current[w])
            if weights[i] <= w:
                current[w] = max(current[w], prev[w-weights[i]] + values[i])
        prev = list(current)

    return prev[-1]

# weights = [10, 20, 30]
# values = [60, 100, 120]
print(knapsack(weights, values, s))
N=int(input())
L=[list(map(int,input().split())) for i in range(N)]
x=[]
y=[]
h=[]
for l in L:
    x.append(l[0])
    y.append(l[1])
    h.append(l[2])
Cx=0
Cy=0
H=0

for i in range(101):#Cx
    for j in range(101):#Cy
        flag=True
        for k in range(N):
            if h[k]!=0:
                H=h[k]+abs(i-x[k])+abs(j-y[k])
                break

        for k in range(N):
            if h[k]!=max(H-abs(i-x[k])-abs(j-y[k]),0):
                flag=False
                break
        
        if flag==True:
            Cx,Cy=i,j
            break
    if flag==True:
        break
print("{} {} {}".format(Cx,Cy,H))
       

### FIXED CODE ###

n=int(input())
if n==1:
    print('Hello World')
else:
    p=[int(input()) for i in range(n)]
    print(sum(p))
import math

X = int(input())
x = round(math.sqrt(X), 0)
flag = 0

for i in range(100):
  for j in range(2, x):
    if X % j == 0:
      flag = 1
      break
  if flag == 0:
    break
  else:
    flag = 0
	X += 1

print(X)

### FIXED CODE ###

import math

X = int(input())
x = int(round(math.sqrt(X), 0))
flag = 0

for i in range(100):
    for j in range(2, x):
        if X % j == 0:
            flag = 1
            break
    if flag == 0:
        break
    else:
        flag = 0
        X += 1
print(X)
n = int(input())
S = list(map(int, input(). split()))
q = int(input())
T = list(map(int, input(). split()))

print(len(S & T))

### FIXED CODE ###

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

Sum = 0

for i in T:
  if i in S:
    Sum += 1
print(Sum)
a, b = int(input(x) for x in input().split())
print((a*b)/2, (a+b)*2)



### FIXED CODE ###

a, b = (int(x) for x in input().split())
area = a*b
perimeter = (a+b)*2
print(area, perimeter)
#106
n = int(input())
if(n<105):
    print(0)
elif(n<135):
    print(1)
elif(n<165):
    print(2)
elif(n<189)
    print(3)
elif(n<195):
    print(4)
else:
    print(5)

### FIXED CODE ###

#106
n = int(input())
if(n<105):
    print(0)
elif(n<135):
    print(1)
elif(n<165):
    print(2)
elif(n<189):
    print(3)
elif(n<195):
    print(4)
else:
    print(5)
#include <bits/stdc++.h>
using namespace std;

int main(){
  int a, b, t;
  cin >> a >> b >> t;
  cout << (t / a) * b << endl;
}

### FIXED CODE ###

a, b, t=map(int,input().split())
print((t//a)*b)
while True:
  x,y=map(int,input().split())

  if x<y:
    print(x,y)

  elif y<x:
    print(y,x)

  elif x and y !=0:
    print(x,y)



### FIXED CODE ###

while True:
  x,y=map(int,input().split())
  
  if x<y:
    print(x,y)
    continue
  
  elif y<x:
    print(y,x)
    continue

  elif x and y !=0:
    print(x,y)
    continue

  elif x==y==0:
    break
import sys
def I(): int(sys.stdin.readline())
def LI(): [int(x) for x in sys.stdin.readline().split()]
mod = 998244353


def main():
    N = I()
    A = LI()

    if A[0] != 0:
        return 0

    DistCnt = [0] * (max(A)+1)
    for i in range(N):
        DistCnt[A[i]] += 1

    if DistCnt[0] != 1:
        return 0

    ans = 1
    for i in range(1,len(DistCnt)):
        ans *= pow(DistCnt[i-1],DistCnt[i],mod)
        ans %= mod
    return ans

if __name__ == "__main__":
    print(main())


### FIXED CODE ###

mod = 998244353
n = int(input())
A = [int(x) for x in input().split()]

if A[0] != 0:
    print(0)
else:
    L = [0]*(n+1)
    for i in range(n):
        L[A[i]] += 1

    if L[0]!=1:
        print(0)
    else:
        ans = 1
        for i in range(1,n+1):
            if L[i]>0:
                for k in range(L[i]):
                    ans *= L[i-1]
                    ans %= mod
            else:
                nxt = i
                break
        for j in range(nxt,n+1):
            if L[j] != 0:
                print(0)
                break
        else:
            print(ans)
s=input()
if s="Sunny":
  print("Cloudy")
if s="Cloudy":
  print("Rainy")
else:
  print("Sunny")

### FIXED CODE ###

s=input()
if s=="Sunny":
  print("Cloudy")
elif s=="Cloudy":
  print("Rainy")
else:
  print("Sunny")
n, k, q = map(int, input().split())

scores = [0 for i in range(n)]

for a in range(q):
    scores[a-1] += 1

for s in scores:
    if q - s >= k:
        print('No')
    else:
        print('Yes')

### FIXED CODE ###

n, k, q = map(int, input().split())

scores = [0 for i in range(n)]

for i in range(q):
    a = int(input())
    scores[a-1] += 1

for s in scores:
    if q - s >= k:
        print('No')
    else:
        print('Yes')
s=input()
if len(s)==2:
  print(s)
else:
  print(s.reverse())

### FIXED CODE ###

s=input()
if len(s)==2:
  print(s)
else:
  s2=s[-1]+s[1]+s[0]
  print(s2)
def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x
  
N = int(input())
lst = list(map(int, input().split()))
const = 10**9 + 7

L = lcm(lst)
answer = 0
for i in lst:
  answer += L / i
answer %= const

print(int(answer))


### FIXED CODE ###

def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x
  
N = int(input())
lst = list(map(int, input().split()))
const = 10**9 + 7

def solve(arr):
    ab = lcm(arr)
    sum = 0
    for a in arr:
        sum += ab // a
    return sum % const

answer = solve(lst)

print(int(answer))
a = list(map(int, input().split()))
a.insert(0, 0)
a.append(0)
distance = [0] * (n + 1)
total = 0
for i in range(1, n + 2):
    distance[i - 1] = a[i] - a[i - 1]
    total += abs(a[i] - a[i - 1])
for i in range(1, n + 1):
    diff = abs(distance[i]) + abs(distance[i - 1]) - \
        abs(distance[i] + distance[i - 1])
    print(total - diff)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a.insert(0, 0)
a.append(0)
distance = [0] * (n + 1)
total = 0
for i in range(1, n + 2):
    distance[i - 1] = a[i] - a[i - 1]
    total += abs(a[i] - a[i - 1])
for i in range(1, n + 1):
    diff = abs(distance[i]) + abs(distance[i - 1]) - abs(distance[i] + distance[i - 1])
    print(total - diff)
s = input()
c = 0
ans = []
for a in s:
    if a in ["A", "C","G", "T"]:
        c += 1
    else:
        ans.append(cnt)
        c = 0
print(max(ans))

### FIXED CODE ###

s = input()
cnt = 0
res = []
res.append(0)
for a in s:
    if a in ["A", "G", "C", "T"]:
        cnt += 1
    else:
        res.append(cnt)
        cnt = 0
    res.append(cnt)
print(max(res))
x = input()
return x^3

### FIXED CODE ###

x = input()
print x * x * x
n = int(input())
a = list(map(int, input().split()))
def devide2a(x):
    
def devide2b(y):
    if x % 2 == 0:
        return int(n / 2)
    else:
        return int((n - 1) / 2)
for j in range(n):
    a[j] = a[j] - (j + 1)
a.sort()
if x % 2 == 0:
    print(sum(a[n / 2:]) - sum(a[:n / 2])
else:
    print(sum(a[(n + 1) / 2:]) - sum(a[:(n - 1) / 2])

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
for j in range(n):
    a[j] = a[j] - (j + 1)
a.sort()
if n % 2 == 0:
    print(sum(a[int(n / 2):]) - sum(a[:int(n / 2)]))
else:
    print(sum(a[int((n + 1) / 2):]) - sum(a[:int((n - 1) / 2)]))
s,w=map(int(),input().split())
 
if s>w:
  print("safe")
else:
  print("unsafe")

### FIXED CODE ###

s,w=map(int,input().split())
 
if s>w:
	print("safe")
else:
	print("unsafe")
N=int(input())
L=list(map(int,input().split()))
A=1
for i in range(N):
  A=A*L[i]
  if 10**18<A:
print(-1)
  exit()
print(A)

### FIXED CODE ###

N=int(input())
L=list(map(int,input().split()))
A=1
if 0 in L:
  print(0)
  exit()
for i in range(N):
  A=A*L[i]
  if 10**18<A:
    print(-1)
    exit()
print(A)
MOD = 1000000007

n, a, b = map(int, input().split())

# https://tex2e.github.io/blog/crypto/modular-mul-inverse
def xgcd(a, b):
	x0, y0, x1, y1 = 1, 0, 0, 1
	while b != 0:
		q, a, b = a // b, b, a % b
		x0, x1 = x1, x0 - q * x1
		y0, y1 = y1, y0 - q * y1
	return a, x0, y0

# https://tex2e.github.io/blog/crypto/modular-mul-inverse
def modinv(a, m):
	g, x, y = xgcd(a, m)
	if g != 1:
		raise Exception('modular inverse does not exist')
	else:
		return x % m

def combination(n, r):
	ans = 1
	for i in range(n - r + 1, n + 1):
		ans *= i
		ans %= MOD
	for i in range(1, r + 1):
		ans *= modinv(i, MOD)
		ans %= MOD
	return ans

ans = 0
ans += pow(2, n, MOD)
 - 1
ans += MOD - combination(n, a)
ans += MOD - combination(n, b)
ans %= MOD

print(ans)


### FIXED CODE ###

MOD = 1000000007

n, a, b = map(int, input().split())

# https://tex2e.github.io/blog/crypto/modular-mul-inverse
def xgcd(a, b):
	x0, y0, x1, y1 = 1, 0, 0, 1
	while b != 0:
		q, a, b = a // b, b, a % b
		x0, x1 = x1, x0 - q * x1
		y0, y1 = y1, y0 - q * y1
	return a, x0, y0

# https://tex2e.github.io/blog/crypto/modular-mul-inverse
def modinv(a, m):
	g, x, y = xgcd(a, m)
	if g != 1:
		raise Exception('modular inverse does not exist')
	else:
		return x % m

def combination(n, r):
	ans = 1
	for i in range(n - r + 1, n + 1):
		ans *= i
		ans %= MOD
	for i in range(1, r + 1):
		ans *= modinv(i, MOD)
		ans %= MOD
	return ans

ans = 0
ans += pow(2, n, MOD) - 1
ans += MOD - combination(n, a)
ans += MOD - combination(n, b)
ans %= MOD

print(ans)
n=int(input())
c=list(map(int, input().split()))
a=list(range(n,n**2+1,n))
b=a[::-1]
for i in range(n):
    b[c[i]-1]+=i
print(*a,'\n',*b)

### FIXED CODE ###

n=int(input())
c=list(map(int, input().split()))
a=list(range(n,n**2+1,n))
b=list(range(n**2,0,-n))
for i in range(n):
    b[c[i]-1]+=i
    
for i in a:
    print(i,end=' ')
print()
for i in b:
    print(i,end=' ')
print()
x = int(input())

def prime(n):
  a = int(n**(1/2))
  for i in range(2,a+1):
    if n%i==0: return False
  return true

while (1):
  if prime(x)==False: x += 1
  else: break
  x += 1
print(x)


### FIXED CODE ###

n = int(input())

import math
def prime(n):
  a = math.ceil(math.sqrt(n))
  for i in range(2,a):
    if n%i==0: return 1
  return 0

while (1):
  if prime(n)==0: 
    print(n)
    exit()
  n+=1
import math
a = int(input())
for i in range(a, 0, -1):
  for j in range(2, 10):
    if i == int(math.paw(i, 1/j)) ** j:
      print(i)
      break
  else:
    continue
  break



### FIXED CODE ###

a = int(input())
print(max(j ** i for j in range(32) for i in range(2, 10) if j ** i <= a))
N=int(input())
s=input()
if s.count('R')>s.count('B'):
    print('Yes')
else:
    print('No')


### FIXED CODE ###

A,B,C=map(int,input().split())
if A==C and A==B:
    print('Yes')
else :
    print('No')
# -*- coding: utf-8 -*-

infinity = pow(10, 9) + 1


def merge(ns, left, mid, right):
    global count
    n1 = mid - left
    n2 = right - mid
    # left_ns = [e for e in range(n1 + 1)]
    # right_ns = [e for e in range(n2 + 1)]
    left_ns = ns[left:mid]
    right_ns = ns[mid:right]

    # for i in range(n1):
    #     left_ns[i] = ns[left + i]
    # for i in range(n2):
    #     right_ns[i] = ns[mid + i]
    
    left_ns[n1] = infinity
    right_ns[n2] = infinity

    i = 0
    j = 0
    for k in range(left, right):
        count += 1
        if left_ns[i] <= right_ns[j]:
            ns[k] = left_ns[i]
            i += 1
        else:
            ns[k] = right_ns[j]
            j += 1


def merge_sort(ns, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(ns, left, mid)
        merge_sort(ns, mid, right)
        merge(ns, left, mid, right)


n = int(input())
ns = [int(e) for e in input().split()]
left = 0
right = len(ns)
count = 0
merge_sort(ns, left, right)

print(*ns)
print(count)

### FIXED CODE ###

# -*- coding: utf-8 -*-

infinity = pow(10, 9) + 1


def merge(ns, left, mid, right):
    global count
    left_ns = ns[left:mid] + [infinity]
    right_ns = ns[mid:right] + [infinity]
    i = j = 0
    for k in range(left, right):
        count += 1
        if left_ns[i] <= right_ns[j]:
            ns[k] = left_ns[i]
            i += 1
        else:
            ns[k] = right_ns[j]
            j += 1


def merge_sort(ns, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(ns, left, mid)
        merge_sort(ns, mid, right)
        merge(ns, left, mid, right)


n = int(input())
ns = [int(e) for e in input().split()]
# n = 10
# ns = [8, 5, 9, 2, 6, 3, 7, 1, 10, 4]
left = 0
right = len(ns)
count = 0
merge_sort(ns, left, right)

print(*ns)
print(count)
N = int(input())
A = list(map(int, input().split()))
maxim = max(A)
counter = [0]*(maxim+1)
dif = [-1, 0, 1]
for a in A:
    for d in dif:
        if a == 0:
            counter[0] += 1
            counter[1] += 1
            break
        elif a == maxim:
            counter[maxim-1] += 1
            counter[maxim] += 1
        else:
            counter[a+d] += 1
print(max(counter))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
maxim = max(A)
counter = [0]*(maxim+1)
dif = [-1, 0, 1]
for a in A:
    for d in dif:
        i = a + d
        if i < 0 or maxim < i:
            continue
        else:
            counter[i] += 1
print(max(counter))
N=int(input())
if N%2 == 1:
    print(0)
else:
    d = 5
    count=0
    while N>1:
        n = N
        while n%d == 0:
            count+=1
            n/=d
    N-=2
print(count)


### FIXED CODE ###

A=[1,2,3]
a=int(input())
b=int(input())
A.remove(a)
A.remove(b)
print(A[0])
inp = [input() for _ in range(2)]
s = inp[0]
t = inp[1]

s = list(s)
t = list(t)
check = []
for i in t:
    if i in s:
        s[s.index(i)] = 0
    check.append(0)

if s == check:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

task = input().split()
for i, j in enumerate(task):
    task[i] = int(j)
task.sort()
score = int(task[2])  - int(task[0])
print(score)
s = []
while True:
    x = raw_input()
    if x == '': break
    s.append(x.lower())
s = ''.join(s)

for i in range(26):
    c = chr(i + 97)
    print '%s : %d' %(c, s.count(c))

### FIXED CODE ###

s = []
while True:
    try: 
        x = raw_input()
    except:
        break
    s.append(x.lower())
s = ''.join(s)

for i in range(26):
    c = chr(i + 97)
    print '%s : %d' %(c, s.count(c))
#coding=UTF-8
import math

N=int(input())
ans=1
for idx in range(0,N,1):
    T=int(input())
    ans=ans*T// math.gcd(ans,T)

print(ans)


### FIXED CODE ###

#coding=UTF-8
#import math
import fractions

N=int(input())
ans=1
for idx in range(0,N,1):
    T=int(input())
    ans=ans*T// fractions.gcd(ans,T)

print(ans)
l= [int(input()) for in range(3)]
c = collections.Counter(l)

print(len(c))

### FIXED CODE ###

x,y,z = map(int,input().split())
if x == y and y==z:
  print(1)
elif x == y or y == z or z ==x :
  print(2)
else:
  print(3)
import sys
sys.setrecursionlimit(int(1e9))



class uft:
  def __init__(self, N):
    self.__N = N
    self.__arr = [-1] * (N + 1)
  def fp(self, x):
    if self.__arr[x] < 0:
      return x
    else:
      self.__arr[x] = self.fp(self.__arr[x])
      return self.__arr[x]
  def add(self, x, y):
    if x == y:
      return 1
    px = self.fp(x)
    py = self.fp(y)
    if px > py:
      px, py = py, px
    self.__arr[px] += self.__arr[py]
    self.__arr[py] = px
  def groups(self):
    ret = -1
    for i in self.__arr:
      if i < 0:
        ret += 1
    return ret
  
N, M = map(int, input().split()) 
UFT = uft(N)

for i in range(M):
  A, B = map(int, input().split())
  UFT.add(A,B)
print(UFT.groups() -1)


### FIXED CODE ###

import sys
sys.setrecursionlimit(int(1e9))

class uft:
  def __init__(self, N):
    self.__N = N
    self.__arr = [-1] * (N + 1)
  def fp(self, x):
    if self.__arr[x] < 0:
      return x
    else:
      self.__arr[x] = self.fp(self.__arr[x])
      return self.__arr[x]
  def add(self, x, y):
    px = self.fp(x)
    py = self.fp(y)
    if px > py:
      px, py = py, px
    if px == py:
      return 1
    self.__arr[px] += self.__arr[py]
    self.__arr[py] = px
  def groups(self):
    ret = -1
    for i in self.__arr:
      if i < 0:
        ret += 1
    return ret
  def show_arr(self):
    print(self.__arr)
  
N, M = map(int, input().split()) 
UFT = uft(N)

for i in range(M):
  A, B = map(int, input().split())
  UFT.add(A,B)
print(UFT.groups() -1)
a = list(map(int,list(input())))
c = 1
co = 0
p = a[0]
pp = []
for i in range(len(a)-1):
	if a[(i+1)] == p:
		c += 1
	else:
		pp.append(c)
		c = 1
		p = a[i+1]
ppp = pp[0]

kkk = 0
for i in range(len(pp)-1):
	if pp[i] >= 0:
		co += 2*(max(pp[i],pp[i+1]) - abs(pp[i] - pp[i+1]))
		pp[i+1] = pp[i+1] - pp[i]
	else:
		pp[i+1] = pp[i+1] - pp[i]
print(co)


### FIXED CODE ###

a = list(map(int,list(input())))
c = 1
co = 0
p = a[0]
pp = []
for i in range(len(a)-1):
	if a[(i+1)] == p:
		c += 1
	else:
		pp.append(c)
		c = 1
		p = a[i+1]
pp.append(c)
if len(pp) != 1:
	ppp = pp[0]
	for i in range(len(pp)-1):
		if pp[i] >= 0:
			co += 2*(max(pp[i],pp[i+1]) - abs(pp[i] - pp[i+1]))
			pp[i+1] = pp[i+1] - pp[i]
		else:
			pp[i+1] = pp[i+1] - pp[i]
print(co)
N,Y = map(int,input().split())
if N*10000 == Y:
    print(N,0,0)
else:
    for a in range(N):
        for b in range (N+1-a):
            if a*10000+b*5000+1000*(N-a-b) == Y:
                print(a,b,N-a-b)
                break
        if a*10000+b*5000+1000*(N-a-b) == Y:
            break

if a == N-1 and  b == 1 and a*10000 + b*5000 < Y:
    print(-1,-1,-1)

### FIXED CODE ###

N,Y = map(int,input().split())
for a in range(N+1):
    for b in range (N+1-a):
        if a*10000+b*5000+1000*(N-a-b) == Y:
            print(a,b,N-a-b)
            exit()
print(-1,-1,-1)
X, N = map(int,input().split())


if N == 0:
    print(X)
else:
    P = list(map(int,input().split()))
    min_abs = 99999
    min_abs_list = []
    search_list = [i for i in range(1,101) if i not in P]
    
    
    
    for p in search_list:
        diff = abs(X-p)
        if diff < min_abs:
            min_abs = diff
            min_abs_list=[]
            min_abs_list.append(p)
        if diff == min_abs:
            min_abs_list.append(p)
        
    print(min(min_abs_list))

### FIXED CODE ###

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


if N == 0:
    print(X)
else:
    P = list(map(int,input().split()))
    i = 0
    while(True):
        # print(X-i)
        if X-i not in P:
            print(X-i)
            break
        elif X+i not in P:
            print(X+i)
            break
        if i > 120:
            break
        i +=1