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

# coding:utf-8
import fractions


def main():
    N = int(input())
    num = list(map(int, input().split()))
    # num.sort()
    # print(num)
    # print(num[0:0])
    gcd = 0
    for i in range(len(num)):
        temp_list = num[0:i] + num[i+1:]
        temp_gcd = temp_list[0]
        for i in temp_list:
            temp_gcd = fractions.gcd(temp_gcd, i)
            if temp_gcd < gcd:
                break
        # temp_gcd = functools.reduce(math.gcd, temp_list)
        if temp_gcd > gcd:
            gcd = temp_gcd
    print(gcd)
    # ans = 0
    # print()


if __name__ == "__main__":
    main()


### FIXED CODE ###

# coding:utf-8
import fractions


def main():
    N = int(input())
    # N = 10 ** 5
    num = list(map(int, input().split()))
    # num = list(range(1, 10**5 + 1))
    # num.sort()
    gcd = 0
    gcd_list_front = []
    gcd_list_back = []
    gcd_list_front.append(num[0])
    gcd_list_back.append(num[-1])

    for i in range(1, N-1):
        gcd_list_front.append(fractions.gcd(gcd_list_front[i-1], num[i]))
        gcd_list_back.append(fractions.gcd(gcd_list_back[i-1], num[-i-1]))

    gcd_list_back.reverse()
    # print(gcd_list_front)
    # print(gcd_list_back)

    gcd = max(gcd_list_back[0], gcd_list_front[-1])

    for i in range(0, N-2):
        # print(gcd_list_front[i], gcd_list_back[i+1])
        temp_gcd = fractions.gcd(gcd_list_front[i], gcd_list_back[i+1])
        if temp_gcd > gcd:
            gcd = temp_gcd

    print(gcd)
    # ans = 0
    # print()


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

n,m=map(int,input().split())
CARD=[0]*n
for i in range(m):
    L,R=map(int,input().split())
    for j in range(L-1,R):
        CARD[j]+=1
ans=0
for i in range(n):
    if CARD[i]==m:ans+=1
print(ans)

### FIXED CODE ###

n,m=map(int,input().split())
CARD=[0]*(n+1)
for i in range(m):
    L,R=map(int,input().split())
    CARD[L-1]+=1
    CARD[R]-=1
ans=0
for i in range(n):
    if CARD[i]==m:ans+=1
    CARD[i+1]=CARD[i+1]+CARD[i]

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

import sys
#from fractions import Fraction

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def a(s):
	if s.count('.')==0:
		return int(s)*(10**10)
	else:
		p = s.index('.')
		if p == 1 and s[0]=='0':
			return int(s[2:]+('0'*(12-len(s))))
		else:
			return int(s[:p]+s[p+1:]+('0'*(11-len(s)+p)))


def main():
	n = int(input())
	#b , c = tin()
	al = [a(input()) for _ in range(n)]
	ret = 0
	for i, vi in enumerate(al):
		for vj in al[i+1:]:
			#pa((vi*vj)/(10**20))
			if (vi*vj) % (10**20)==0:
				ret += 1
	return ret
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

### FIXED CODE ###

import sys
#from fractions import Fraction
import collections

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def a(s):
	if s.count('.')==0:
		n2=0
		n5=0
		v = int(s)
	else:
		p = s.index('.')
		n2 = -(len(s) - p - 1)
		n5 = -(len(s) - p - 1)
		if p == 1 and s[0]=='0':
			v= int(s[2:])
		else:
			v = int(s[:p]+s[p+1:])
	while v % 2 == 0:
		v = v//2
		n2+=1
	while v % 5 == 0:
		v = v//5
		n5+=1
	return str(n2)+'_'+str(n5)

def main():
	n = int(input())
	#b , c = tin()
	al = [a(input()) for _ in range(n)]
	cal = collections.Counter(al)
	#pa(cal)
	ret = 0
	pp = set()
	for k in cal:
		for k2 in cal:
			if k+'_'+k2 in pp:
				continue
			#pa((vi*vj)/(10**20))
			if k==k2:
				a2, a5 = map(int, k.split('_'))
				if a2>=0 and a5 >= 0:
					ret += cal[k]*(cal[k]-1)//2
			else:
				a2, a5 = map(int, k.split('_'))
				b2, b5 = map(int, k2.split('_'))
				if a2+b2 >= 0 and a5+b5 >= 0:
					ret += cal[k]*cal[k2]
				
			pp.add(k+'_'+k2)
			pp.add(k2+'_'+k)
			#pa((k,k2,ret))
			
	return ret
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)
### BUGGY CODE ###

import numpy as np
k = int(input())

ans = 0
for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      ans += np.gcd(np.gcd(a,b),c)

print(ans)


### FIXED CODE ###

import math
k = int(input())

ans = 0
for a in range(1,k+1):
  for b in range(1,k+1):
    tmp = math.gcd(a,b)
    for c in range(1,k+1):
      ans += math.gcd(c,tmp)

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

import heapq
def SME():
    A = []
    ANS = [None] * N
    C = set([i for i in range(N)])
    D = set([])
    E = [None] * N
    parameter = 0.9997
    count = 0
    for i,x in enumerate(Whole) :
        if 0 in E[i-L//2:i] and 0 in E[i:i+L//2+1] :
            E[i] = 0
            continue
        E[i] = 0
        heapq.heappush(A,[x,i])
    for j in range(N) :
        a = heapq.heappop(A)
        for i in range(L):
            idx = a[1] + i
            try :
                if ANS[idx] : continue
                else :
                    ANS[idx] = a[0]
                    D.add(idx)
                    count += 1
            except IndexError : continue
        if count > N * parameter : break
    for i in C.difference(D):
        if i < L : ANS[i] = min(Whole[:i+1])
        else : ANS[i] = min(Whole[i+1-L:i+1])
    return ANS

[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
ANS = SME()
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

from collections import deque


def main():
    h,w,k = map(int,input().split())
    x,y,gx,gy = map(int,input().split())
    x -= 1
    gx -= 1
    y -= 1
    gy -= 1
    c = [list(input()) for _ in range(h)]
    d = [[-1 for _ in range(w)] for _ in range(h)]
    dx = (1, 0, -1, 0)
    dy = (0, 1, 0, -1)
    que = deque()
    que.append((x,y))
    d[x][y] = 0
    while que:
        (qx,qy) = que.popleft()
        if qx == gx and qy == gy:
            break
        for i in range(4):
            for K in range(1,k+1):
                nx = qx + dx[i]*K
                ny = qy + dy[i]*K
                if not(nx>=0 and h>nx and ny>=0 and w>ny) or c[nx][ny] == '@':
                    break
                if d[nx][ny] == -1 or d[nx][ny] > d[qx][qy]+1:
                    d[nx][ny] = d[qx][qy] + 1
                    que.append((nx,ny))
    print(d[gx][gy])


if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import deque
def main():
    h,w,k = map(int,input().split())
    x,y,gx,gy = map(int,input().split())
    x -= 1
    gx -= 1
    y -= 1
    gy -= 1
    c = [list(input()) for _ in range(h)]
    d = [[-1 for _ in range(w)] for _ in range(h)]
    dx = (1, 0, -1, 0)
    dy = (0, 1, 0, -1)
    que = deque()
    que.append((x,y))
    d[x][y] = 0
    while que:
        (qx,qy) = que.popleft()
        if qx == gx and qy == gy:
            break
        for i in range(4):
            for K in range(1,k+1):
                nx = qx + dx[i]*K
                ny = qy + dy[i]*K
                if not(nx>=0 and h>nx and ny>=0 and w>ny) or c[nx][ny] == '@' or (d[nx][ny] != -1 and d[nx][ny] < d[qx][qy]+1):
                    break
                if d[nx][ny] == -1 or d[nx][ny] > d[qx][qy]+1:
                    d[nx][ny] = d[qx][qy] + 1
                    que.append((nx,ny))
    print(d[gx][gy])
 
 
if __name__ == "__main__":
    main()
### BUGGY CODE ###

def main():
    S = input()
    Q = int(input())
    reverse = False
    front = ""
    back = ""
    for _ in range(Q):
        TFC = list(input().split())
        if len(TFC) == 1:
            reverse = not(reverse)
        else:
            t,f,c = TFC
            if reverse:
                if f == "2":
                    front += c
                else:
                    back += c

            else:
                if f == "1":
                    front += c
                else:
                    back += c
    if reverse:
        print(back[::-1] + S[::-1] + front)
    else:
        print(front[::-1] + S + back)
    return

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    S = input()
    Q = int(input())
    reverse = False
    front = []
    back = []
    for _ in range(Q):
        TFC = list(input().split())
        if len(TFC) == 1:
            reverse = not(reverse)
        else:
            t,f,c = TFC
            if reverse:
                if f == "2":
                    front.append(c)
                else:
                    back.append(c)

            else:
                if f == "1":
                    front.append(c)
                else:
                    back.append(c)
    if reverse:
        print("".join(back[::-1]) + S[::-1] + "".join(front))
    else:
        print("".join(front[::-1]) + S + "".join(back))
    return

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

H,W,D = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(H)]
Q = int(input())
LR = [list(map(int,input().split())) for _ in range(Q)]

data = {A[i][j]:j + i * W for i in range(H) for j in range(W)}

memo = [[None] * (H*W+1) for _ in range(H*W+1)]
for i in range(1+D,H*W+1):
    a,b = data[i],data[i-D]
    memo[i-D][i] = abs(a%W - b % W) + abs(a//W - b//W)

for l,r in LR:
    if l == r:
        print(0)
        continue
    if memo[l][r]:
        print(memo[l][r])
        continue
    t = 0
    now = l
    while now != r:
        t += memo[now][now+D]
        now += D
        memo[l][now] = t
    print(t)

### FIXED CODE ###

H,W,D = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(H)]
Q = int(input())
LR = [list(map(int,input().split())) for _ in range(Q)]

data = {A[i][j]:j + i * W for i in range(H) for j in range(W)}

memo = [0] * (H*W+1)
for i in range(1+D,H*W+1):
    a,b = data[i],data[i-D]
    memo[i] = memo[i-D] + abs(a%W - b % W) + abs(a//W - b//W)

for l,r in LR:
    if l == r:
        print(0)
        continue
    print(memo[r] - memo[l])
### BUGGY CODE ###

n = 1000000007
 
def comb(p,q):
    r = 1
    for i in range(q):
        r = r * (p-i) // (1+i)
    return r%n
    
    
r1,c1,r2,c2 = list(map(int,input().split()))
 
 
y = comb(r2+c2+2,c2+1) - comb(r2+c1+1,c1) - comb(r1+c2+1,c2+1) + comb(r1+c1,c1)
print(y % n)

### FIXED CODE ###

M=1000000007
r1,c1,r2,c2=map(int,input().split())
n=r2+c2+2
fac=[1]+[0]*n
for i in range(1,n+1):fac[i]=fac[i-1]*i%M
f=lambda r,c:fac[r+c+2]*pow(fac[c+1],M-2,M)*pow(fac[r+1],M-2,M)-1
print((f(r2,c2)-f(r2,c1-1)-f(r1-1,c2)+f(r1-1,c1-1))%M)
### BUGGY CODE ###

import math

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    min_ind = a.index(min(a))

    start = sorted([min_ind - x for x in range(k) if min_ind - x >= 0])
    end = [s+k-1 for s in start]

    ans = 10**6
    for s, e in zip(start, end):
        ans = min(ans, math.ceil(len(a[:s])/(k-1)) + math.ceil(len(a[e+1:])/(k-1)))

    print(ans+1)

main()

### FIXED CODE ###

import math

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    min_ind = a.index(min(a))

    start = [min_ind - x for x in range(k) if min_ind - x >= 0]
    end = [s+k-1 for s in start]

    ans = 10**6
    for s, e in zip(start, end):
        ans = min(ans, math.ceil(s/(k-1)) + math.ceil((n-(e+1))/(k-1)))

    print(ans+1)

main()
### BUGGY CODE ###

N = int(input())
arr = list(input())
R = []
G = []
B = []
result = 0
for i in range(len(arr)):
  if arr[i] == "R":
    R.append(i)
  elif arr[i] == "G":
    G.append(i)
  elif arr[i] == "B":
    B.append(i)

for i in R:
  for j in G:
    for k in B:
      if abs(j - i) == abs(k - j) or abs(j - i) == abs(i - k) or abs(k - i) == abs(k - j):
        result += 1
print(len(R) * len(G) * len(B) - result)

### FIXED CODE ###

N = int(input())
arr = list(input())
a = arr.count("R")
b = arr.count("G")
c = arr.count("B")
count = a * b * c

for i in range(N - 2):
  for j in range(i + 1, N - 1):
    k = i + (j - i) * 2
    if k < N and arr[i] != arr[j] and arr[j] != arr[k] and arr[k] != arr[i]:
      count -= 1
print(count)
### BUGGY CODE ###

import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import defaultdict
def main():
    n, x, y= map(int, input().split())
    x -= 1
    y -= 1
    dis = defaultdict(int)
    for i1 in range(n):
        for i2 in range(n):
            d = min(abs(i2-i1), abs(x-i1)+abs(y-i2)+1, abs(x-i2)+abs(y-i1)+1)
            dis[d] += 1

    for k1 in range(1, n):
        print(dis[k1]//2)

if __name__ == '__main__':
    main()


### FIXED CODE ###


import sys
input = sys.stdin.readline
from collections import deque
from collections import Counter
def main():
    # 入力
    n, x, y = map(int, input().split())
    x -= 1
    y -= 1

    # 処理
    dis = deque()
    for i1 in range(n):
        if x < i1:
            right = i1 + 1
            while right < n:
                dis_now = min(right - i1, (i1 - x + abs(right - y) + 1))
                dis.append(dis_now)
                right += 1
        else:
            right = i1 + 1
            while right < n:
                if right < y:
                    dis_now = min(right - i1,(x - i1 + abs(y - right) + 1))
                    dis.append(dis_now)
                else:
                    dis.append(right - i1 - (y - x) + 1)
                right += 1
    dis_c = Counter(dis)
    dis_list = [0] * (n - 1)
    for i2 in range(1, n):
        dis_list[i2 - 1] = dis_c[i2]

    # 出力

    for edis in dis_list:
        print(edis)

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


from bisect import bisect_left

N = int(input())
S = input()

d = {"R": [], "G": [], "B": []}
for i in range(N):
    d[S[i]].append(i)

ctr = {}
for v in "RGB":
    ctr[v] = len(d[v])

ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        if S[i] == S[j]:
            continue

        # j > k
        res = (set("RGB") - set([S[i], S[j]])).pop()
        k = bisect_left(d[res], j)

        # Find k == 2*j - i
        k0 = bisect_left(d[res], 2 * j - i)
        if k0 < ctr[res]:
            flag = int(d[res][k0] + 1 == 2 * (j + 1) - i - 1)
        else:
            flag = 0

        # Add
        ans += ctr[res] - k - flag

print(ans)


### FIXED CODE ###

from bisect import bisect_right

N = int(input())
S = input()

d = [[0] * N for _ in range(3)]
for i in range(3):
    for j in range(N):
        d[i][j] = int(S[j] == "RGB"[i])
        
cumsum = [[0] * (N + 1) for _ in range(3)]
for i in range(3):
    for j in range(N):
        cumsum[i][j + 1] = cumsum[i][j] + d[i][j]

cnt = [len(v) for v in d]
ans = 0
for i in range(1, N - 1):
    for j in range(i + 1, N):
        
        if S[i - 1] == S[j - 1]:
            continue

        # Find `k` string and index
        s = (set("RGB") - set([S[i - 1], S[j - 1]])).pop()
        idx = "RGB".find(s)
        ans += cumsum[idx][-1] - cumsum[idx][j]
        
        k = 2 * j - i
        if k <= N and d[idx][k - 1]:
            ans -= 1
        
print(ans)
### BUGGY CODE ###

import numpy as np
n, m = map(int, input().split())
maze = np.array([list(input()) for _ in range(n)])
a = np.array(maze == "#")
ls = np.argwhere(a)
l = []
c= 0
while True:
  for i in [[1,0],[-1,0],[0,1],[0,-1]]:
    for j,k in ls + i:
      if -1<j<n and -1<k<m:
        if a[j,k] == False:
          a[j,k] = True
          l.append([j,k])
  ls = np.array(l)
  if l==[]:
    break
  l = []
  c += 1
print(c)

### FIXED CODE ###

from collections import deque
n,m = map(int,input().split())

maze = [list(input()) for _ in range(n)]

def bfs():
    dx = (1, 0, -1, 0)
    dy = (0, 1, 0, -1)
    d = [([-1]*m)for _ in range(n)]
    q = deque([])
    for i in range(n):
        for j in range(m):
            if maze[i][j] == "#":
                d[i][j] = 0
                q.append((i,j))
    a = 0

    while q:
        x,y = q.popleft()
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if 0<= nx < n and 0<= ny < m and maze[nx][ny] != '#' and d[nx][ny] == -1:
                q.append((nx,ny))
                d[nx][ny] = d[x][y] +1
                a = max(a,d[nx][ny])
    return a

print(bfs())
### BUGGY CODE ###

import numpy as np
from functools import reduce
import fractions
 
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
 
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
 
n = int(input())

inp_list = list(map(int,(input().split())))

lcm = lcm_list(inp_list)

arr_inp = np.array(inp_list)

arr_inp = lcm // arr_inp

print(np.sum(arr_inp)%(10**9+7))


### FIXED CODE ###

from functools import reduce
import fractions
 
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
 
n = int(input())

inp_list = list(map(int,(input().split())))

lcm = lcm_list(inp_list)

ans = 0
mod = 10**9+7

for i in inp_list:
    ans += lcm // i



print(ans % mod)
### BUGGY CODE ###

import numpy as np
N,C=map(int,input().split())
 
def get_unique_list(seq):
  seen = []
  return [x for x in seq if x not in seen and not seen.append(x)]

Record=np.empty((0,3), int)
 
for i in range(N):
  lis=list(map(int,input().split()))
  n=np.array(lis)
  Record=np.append(Record,[n],axis=0)
#print(Record)


newRecord=np.empty((0,3), int)
for c in range(C):
  Recordi=np.empty((0,3), int)
  for i in range(N):
    if Record[i][2]==c+1:
      Recordi=np.append(Recordi,[Record[i]],axis=0)
  
  sort_Recordi=Recordi[np.argsort(Recordi[:,0])]
  #print(sort_Recordi)
  for j in range(len(sort_Recordi)-1):
    if sort_Recordi[j][1]==sort_Recordi[j+1][0]:
      sort_Recordi[j][1]=sort_Recordi[j+1][1]
      sort_Recordi[j+1][0]=sort_Recordi[j][0]
  sort_Recordi_u=set(map(tuple,sort_Recordi))
  sort_Recordi_u=np.array(list(sort_Recordi_u))
  #print(sort_Recordi_u)
  for k in range(len(sort_Recordi_u)):
    newRecord=np.append(newRecord,[sort_Recordi_u[k]],axis=0)
    
      
#print(newRecord)
nofc=np.zeros(10**5+1)
 
for a in newRecord:
  vec=np.ones(a[1]-a[0]+1)
  nofc[a[0]:a[1]+1]+=vec
#print(vec)
#print(nofc[:13])
print(int(max(nofc)))

### FIXED CODE ###

import numpy as np
N,C=map(int,input().split())

nofc=np.zeros((C,10**5),dtype=int)

for i in range(N):
  s,t,c=map(int,input().split())
  vec=np.ones(t-s+1,dtype=int)
  nofc[c-1][s-1:t]=vec
print(int(max(np.sum(nofc,axis=0))))
### BUGGY CODE ###

A, B, K = map(int, input().split())

for k in range(K):
  if(A != 0):
    A-=1
  elif(B > 0):
    B-=1
print(A, B)

### FIXED CODE ###

A, B, K = map(int, input().split())

if(A - K >= 0):
  A -= K
else:
  if(B+(A-K) >= 0):
    B += A - K
    A = 0
  else:
    A = 0
    B = 0
print(A, B)
### BUGGY CODE ###

from itertools import combinations
def main():
    S = input() + 'T'
    x, y = map(int, input().split())
    moveX, moveY = [], []
    move ={0:moveX, 1:moveY}
    direct = 0
    step = 0
    for s in S:
        if s == 'T':
            move[direct].append(step)
            direct ^= 1
            step = 0
        else:
            step += 1
    
    if possible(x, moveX[1:], sum(moveX)) and possible(y, moveY, sum(moveY)):
        print('Yes')
    else:
        print('No')


def possible(target, move, furthest):
    for k in range(len(move)+1):
        for c in combinations(move,k):
            if furthest-2*sum(c) == target:
                return True
    return False


main()

### FIXED CODE ###

from collections import defaultdict
def main():
    S = input() + 'T'
    x, y = map(int, input().split())
    #データ加工
    moveX, moveY = [], []
    if S[0] == 'T': moveX.append(0)
    move ={0:moveX, 1:moveY}
    direct = 0
    step = 0
    for s in S:
        if s == 'T':
            if step > 0:
                move[direct].append(step)
                step = 0
            direct ^= 1 
        else:
            step += 1
    #判定
    if possible(x, moveX[1:], moveX[0]) and possible(y, moveY):
        print('Yes')
    else:
        print('No')


def possible(target, move, offset=0):
    l = len(move)
    dp = [defaultdict(lambda:False) for _ in range(l+1)]
    #初期化
    dp[0][0] = True
    for i,m in enumerate(move):
        for key in dp[i]:
            dp[i+1][key+m] = True
            dp[i+1][key-m] = True
    return dp[l][target-offset]


main()
### BUGGY CODE ###

from collections import deque
n, m = map(int,input().split())

edge = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
    
visited = [0]*n
visited[0] = 1
q = deque([0])

ans = 0

while sum(visited) < n:
    while q:
        now = q.popleft()
        for to in edge[now]:
            if visited[to] == 0:
                q.append(to)
                visited[to] = 1
    #print(visited)
    if sum(visited) < n:
        ans += 1
        for i,v in enumerate(visited):
            if v == 0:
                q.append(i)
                visited[i] = 1
                break

print(ans)

### FIXED CODE ###

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):#要素xが属するグループの根を返す
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):#要素xが属するグループと要素yが属するグループとを併合する
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):#要素xが属するグループのサイズ（要素数）を返す
        return -self.parents[self.find(x)]
 
    def same(self, x, y):#要素x, yが同じグループに属するかどうかを返す
        return self.find(x) == self.find(y)
 
    def members(self, x):#要素xが属するグループに属する要素をリストで返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):#すべての根の要素をリストで返す
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):#グループの数を返す
        return len(self.roots())
 
    def all_group_members(self):#{ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
        return {r: self.members(r) for r in self.roots()}
 
    def __str__(self):#print()での表示用 ルート要素: [そのグループに含まれる要素のリスト]を文字列で返す
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int,input().split())
uf = UnionFind(n)

edge = []
for i in range(m):
    a,b = map(int,input().split())
    edge.append((a-1,b-1))
    
for a,b in edge:
    uf.union(a, b)
    
print(uf.group_count()-1)