import math
Flag = True
Row_of_bones = []
n = int(input())
for i in range(n):												#Получив кол-во костей, последовательно заполняем список
	x = list(map(int, (input().split())))		#"Налету" превращаем в список с целыми числами
	Row_of_bones.append(x)											#Собственно помещаем кость[xi,yi] в ряд []

def check_parity() -> bool:        #Функция, в которой я пересчитываю верхние и нижние суммы, а затем проверяю на четность.
	upp,low = 0,0
	for i in Row_of_bones:
		upp += i[0]
		low += i[1]
	if (upp % 2 == 0) and (low % 2 == 0):
		return True
	else:
		return False

# Тут подумай над тем какие вообще варианты ответов могут быть.
# сейчас исправить всего одну строку и будет работать, но не слишком быстро

count = 0 # Счетчик действий

while(Flag):
	for x in Row_of_bones:
		if check_parity():# проверка сумм на четность и, если да, то выход
			print(count)
			Flag =False
			break
		elif ((x[0] % 2 == 0) and (x[1] % 2 != 0)) or ((x[0] % 2 != 0) and (x[1] % 2 == 0)): # Меняем только нужные нечет/чет или чет/нечет
			x[0],x[1] = x[1], x[0]
			count+=1 # счетник без лишних движений
		elif count > n: # Если переворачивание нужных костей не приводит к результату, то выходим. Тут я долго думал  как лучше выразить
			print(-1)	# 	бесконечность/бессмысленость действий. Сошелся на count > n
			Flag =False
			break


n=int(input(""))
if(n!=1):
    i=2
    while(i<n):

        if(n%i!=0):
            if(n-i>0):
                n=n-i

                i=2
            else:
                break
        else:
            i=i+1

    print(n)
else:
    print(1)


""" Created by Henrikh Kantuni on 2/26/17 """

if __name__ == '__main__':
    n, k = [int(x) for x in input().split()]

    count = 0
    zero_count = 0

    if k == 0:
        print(0)
        exit()

    if n < 10 ** k:
        count = len(str(n)) - 1
    else:
        for i in range(len(str(n))):
            if n % 10 != 0:
                count += 1
            else:
                zero_count += 1

            n //= 10

            if zero_count == k:
                break

    print(count)


number = list(input())

new_number = []

if len(number) % 2 == 0:

    already_bigger = False

    for digit in number:
        digit = int(digit)

        if already_bigger:
            new_number += [4]
        else:

            if digit == 4 or digit == 7:
                new_number += [digit]
            else:
                already_bigger = True
                if digit < 4:
                    new_number += [4]
                elif digit < 7:
                    new_number += [7]
                else:
                    if 4 in new_number:
                        first_4 = new_number.index(4)
                        new_number = new_number[:first_4] + [7] + [4] * (len(number) - (first_4 + 1))
                        break
                    else:
                        new_number = [4] * (len(number) + 2)
                        break

else:
    new_number = [4] * (len(number) + 1)

of_4, of_7 = new_number.count(4), new_number.count(7)

if of_4 > of_7:
    new_number = list(reversed(new_number))
    missing = (of_4 - of_7)//2
    i = 0
    while missing != 0:
        if new_number[i] == 4:
            new_number[i] = 7
            missing -= 1
        i += 1
    new_number = list(reversed(new_number))
elif of_7 > of_4:
    missing = (of_7 - of_4)//2 + 1
    first_4 = new_number.index(4)
    new_number = reversed(new_number)
    if first_4 < len(new_number)/2:
        i = 0
        while True:
            if missing == 0:
                if new_number[i] == 4:
                    new_number[i] = 7
                    break
            else:
                if new_number[i] == 7:
                    new_number[i] = 4
                    missing -= 1
            i += 1
    else:
        new_number = [7] * (new_number//2 + 1) + [4] + (new_number//2 + 1)

    new_number = list(reversed(new_number))

print(''.join(map(str,new_number)))


from collections import Counter

def helpfulMath():
	c = Counter(raw_input().strip())
	ones = ["1" for i in xrange(c['1'])]
	twos = ["2" for i in xrange(c['2'])]
	threes = ["3" for i in xrange(c['3'])]
	res = ""
	if ones:
		res += "+".join(ones)
	if twos:
		if res:
			res += "+" + "+".join(twos)
		else:
			res += "+".join(twos)
	if threes:
		if res:
			res += "+" + "+".join(threes)
		else:
			res += "+".join(threes)
	return res

print helpfulMath()


values = {}
k = int(input())
s = input()
open = []
result = "NO"

for i in s:
    if i not in values:
        values[i] = 1

    else:
        values[i]+=1

for i in s:
    if i not in open:
        open.append(i)

    if len(open) > k:
        result = "YES"
        break

    if values[i] == 1:
        open.remove(i)

    values[i]-=1

print(result)


from math import log,log2,ceil
for _ in range(1):
	n=int(input())
	a=list(map(int,input().split()))
	p = n//2
	if n%2:
		p+=1
	c=0
	pc,nc=0,0
	for i in a:
		if i==0:
			c+=1

		elif i<0:
			nc+=1
		else:
			pc+=1
	if nc>=p:
		print(-1)
	elif pc>=p:
		print(1)
	else:
		print(0)


def main():
    n, m = map(int, raw_input().split())
    if a == 0 and b == 0:
        print 'NO'
        return
    elif abs(a-b) > 1:
        print 'NO'
    else:
        print 'YES'

if __name__ == '__main__':
    main()


def fun12(n):
    while True:
        n1=n
        for i in range(n+1,0,-1):
            if i%2==0:
                n1=n-i;
                break;
        if n1==n:
            return "Ehab"
        if n1==0:
            return "Mahmoud"

        for i in range(n1+1,0,-1):
            if i%2==1:
                n=n1-i;
                break;

n=int(input())
print(fun12(n))


a = map(int, raw_input().split())
b = list(set(a))
if len(b)==1:
	print "Elephant"
if len(b)==2:
	print "Elephant"
if len(b)==3:
	print "Bear"
if len(b)>3:
	print "Alien"


INF = 1e10
max_n = 50
max_k = 2000
def main():
    n, s, k = map(int, input().split())
    s -= 1
    buf = ['']*(max_n + 1)
    dp = [[0 for i in range(max_n + 1)] for j in range(max_k)]
    r = list(map(int, input().split()))
    c = input()
    answer = INF
    for i in range(len(c)):
        buf[i] = c[i]
    for i in range(k, -1, -1):
        for j in range(n):
            dp[i][j] = INF
    for j in range(n):
        value = abs(j - s)
        if k - r[j] <= 0:
            answer = min(answer, value)
        else:
            dp[k - r[j]][j] = value
    for i in range(k, 0, -1):
        for j in range(n):
            if dp[i][j] < INF:
                for l in range(n):
                    if buf[j] != buf[l] and r[j] < r[l]:
                        value = dp[i][j] + abs(j - l)
                        if i - r[l] <= 0:
                            answer = min(answer, value)
                        else:
                            dp[i - r[l]][l] = min(dp[i - r[l]][l], value)
    if answer == INF:
        print(-1)
        return
    print(answer)

if __name__=="__main__":
    main()


n, k = map(int, raw_input().split())
values = []
for i in range(1, k):
    if n % i != 0:
        continue
    t = n / i
    values.append(i + (t * k))
print min(values)


#from random import random, randint
#from sys import stdout
import math

#n, k = map(int, input().split())
n = int(input())
m = int(input())
a = []
for i in range(n):
    a.append(int(input()))

print(math.ceil((sum(a) + m)/n), max(a) + m)


from collections import deque
n = int(input())
d = set()
k1, *a = [int(s) for s in input().split()]
k2, *b = [int(s) for s in input().split()]
a = deque(a)
b = deque(b)
res = 0
while a and b:
    cu = tuple(tuple(a), tuple(b))
    if not cu in d:
        d.add(cu)
        res += 1
        cur1 = a.popleft()
        cur2 = b.popleft()
        if cur1>cur2:
            a.append(cur2)
            a.append(cur1)
        else:
            b.append(cur1)
            b.append(cur2)
    else:
        print(-1)
        break
else:
    if len(a) > len(b):
        print(res, 1)
    else:
        print(res, 2)


import math
def isTPrime(n):
    count = 0
    if n==2 or n==3: return False
   # print(2,math.ceil(int(n**0.5))+3)
    for i in range(2,math.ceil(int(n**0.5))+3):   # only odd numbers
        if i == n:
            break
        if n%i==0:
            count +=1
        if count == 2:
            break
    if count == 1:
        return True
    else:
        return False
n = int(input())
list = [int(n) for n in input().split()]

for num in list:
    if isTPrime(num):
        print("YES")
    else:
        print("NO")


n, m, a ,b = (int(x) for x in input().split())
x = n
c = n
if n % m ==0:
    print (0)
else:
    while x%m!=0:
        x=x+1
    while c%m!=0:
        c=c-1
    p = (x - n)*a
    s = (n - c)*b
    print(min(p, s))


import sys
sys.stdin = open("test.in","r")
sys.stdout = open("test.out","w")

b=input()
a=0
for i in range(len(b)):
	if b[i]=='a':
		a+=1
print(a+1)


n=input()
if "H"in n:
    print("YES")
elif "Q" in n:
    print("n=input();if 'H'in n:print('YES');elif 'Q' in n:print();elif '9':print('99 Bottles of Beer');elif '+':print(int(n)+1);else:print('NO')")
elif "9" in n:
    print("99 Bottles of Beer")
elif "+":
    print(int(n)+1)

else:
    print("NO")


def cal(a):
    x=0
    while(a>0):
        x+=a%10
        a=a//10
    return x
n,s=input().split()
n=int(n)
s=int(s)
if((n-cal(n))<s):
    print(0)
elif((n-1-cal(n-1))<s):
    print(1)
else:
    u=10
    l=n
    mid=-1
    while(1):
        mid=(u+l)//2
        if((mid-cal(mid))>=s):
            if((mid-1-cal(mid-1))<s):
                break
            else:
                l=mid-1
        else:
            if((mid+1-cal(mid+1))>=s):
                mid+=1
                break
            else:
                u=mid+1
    print(n-mid+1)


n = int(input())
t = 4 * n + 1

p = [[*map(int, input().split())] for _ in range(t)]

for i in p:
	if not ((i[0] in [0, n] and i[1] <= n) or (i[1] in [0, n] and i[0] <= n)):
		print(*i)


A, B = map(int, raw_input().split())
a = reduce(lambda x, y: x * y, [i for i in range(1, A + 1)])
b = reduce(lambda x, y: x * y, [i for i in range(1, B + 1)])
def gcd(x, y):
  return x if y == 0 else gcd(y, x % y)
print gcd(a, b)


k=int(input())
l=[]
l=input().split(" ")
s=0
p=[]
i=0
while i<k:
    if int(l[i])!=0:
        p.append(str(i+1)+" ")
        p.append(str(i+1)+"\n")
        s+=1
    else:
        som=0
        res=i
        for j in range(i+1,k):
            som+=int(l[j])
            i+=1
            if som!=0:
                break
        p.append(str(res+1)+" ")
        p.append(str(i+1)+"\n")
        if som!=0:
            s+=1
    i+=1
if s==0:
    print("NO")
else:
    print("YES")
    print(s)
    print("".join(p))


import itertools
import sys

def check(string):
	j = 0
	while j < len(string) / 2:
		if string[j] == string[len(string)-j-1]:
			j += 1
			continue
		else:
			return False
	return True

string = raw_input()
subsets = []
for i in range(len(string)):
	for j in range(len(list(itertools.combinations(string, i+1)))):
		subsets.append(''.join(list(itertools.combinations(string, i+1))[j]))

for j in range(len(subsets)-1, -1, -1):
	if not check(subsets[j]):
		print len(subsets[j])
		sys.exit()

if check(subsets[len(subsets) - 1]):
	print 0
else:
	print len(string)


import sys
import string

while True:
    try: s = raw_input("")
    except: break

    if len(s) == 0: break

    res = ""

    if s[:3] == "ftp":
        res += "ftp"
        s = s[3:]
        p -= 3
    else:
        res += "http"
        s = s[4:]
        p -= 4

    p = string.find(s, "ru")
    if p == 0:
        p = string.find(s[2:], "ru")
        p += 2

    res += "://"
    res += s[:p]
    res += "."
    res += "ru"

    s = s[p+2:]
    if len(s) > 0: res += "/" + s
    print res
    break


a, b, c = map(int, input().split())
m = 0
while not (a+b > c and b+c > a and a+c > b):
    if a+b <= c and a+c <= b:
        a += 1
        m += 1
    elif a+b <= c and b+c <= a:
        b += 1
        m += 1
    else:
        c += 1
        m += 1
print(m)


n,t=map(int,input().split())
s=input()
for i in range(t):
    c=0
    for j in range(len(s)-1):
        if s[j]=='B' and s[j+1]=='G':
            s[j],s[j+1]=s[j+1],s[j]
            c=1
    if c==0:
        break
print(s)


num = input()
arr = []
counting = 0

for m in range(0, len(num)):
    if num[m] == ' ':
        arr.append(int(num[counting:m]))
        counting = m + 1
    elif m == len(num) - 1:
        arr.append(int(num[counting:len(num)]))

dimension = arr[0]
req_value = arr[1]

data_storing = [[0]*dimension for _ in range(dimension)]

for i in range(0, dimension):
    for j in range(0, dimension):
        data_storing[i][j] = (i + 1) * (j + 1)

count = 0
for x in range(0, dimension):
    for y in range(0, dimension):
        if data_storing[x][y] == req_value:
            count += 1

print(count)


import math
import operator as op

from functools import reduce

from operator import mul    # or mul=lambda x,y:x*y
from fractions import Fraction

def nCk(n,k):
  return int( reduce(mul, (Fraction(n-i, i+1) for i in range(k)), 1) )

def ncr(n, r):
    r = min(r, n-r)
    if r == 0: return 1
    numer = reduce(op.mul, range(n, n-r, -1))
    denom = reduce(op.mul, range(1, r+1))
    return numer//denom

def modPow(a, x, p):
    #calculates a^x mod p in logarithmic time.
    res = 1
    while(x > 0):
        if( x % 2 != 0):
            res = (res * a) % p

        a = (a * a) % p
        x = int(x/2)
    return res

def modInverse(a, p):
    #calculates the modular multiplicative of a mod m.
    #(assuming p is prime).
    return modPow(a, p-2, p)

def modBinomial(n, k, p):
    #calculates C(n,k) mod p (assuming p is prime).

    # n * (n-1) * ... * (n-k+1)
    numerator = 1
    for i in range(k):
        numerator = (numerator * (n-i) ) % p

    denominator = 1
    for i in range(1, k+1):
        denominator = (denominator * i) % p

    # numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p

n, c = input().split()
n = int(n)
c = int(c)

#test = [0 for x in range (n+1)]
#test[1] = c

#for i in range(2, n+1):
#    test[i] = (test[i-1] + modBinomial((i+c-1),i, 1000003))%1000003

#ans = solve(n, c)
#ans =test[n]
ans = modBinomial((c+n),c,1000003) - 1
print(int(ans))


import math
m=int(input())
l=[];
a=0;
j=0;
r=factorial(j);
while(r<10**m):
    j=j+1;
    r=r*j;
while(r%10**m!=0):
    j=j+1;
    r=r*j;
if(factorial(j)%10**(m+1)!=0):
    k=1;
    while(k<=5):
        l=l+[j];
        a=a+1;
        j=j+1;
        k=k+1;
print(a);
for k in l:
    print(k,end=" ");


import sys
sys.stdin=open("input.in","r")
sys.stdout=open("output.out","w")

j=input()
t=input()
m=0
for i in t:
	if j[m]==i:
		m+=1
print(m+1)


trump = input()
cards = input()
if cards[1] == trump:
    if cards[4] != trump:
        print("YES")
    else:
        if int(cards[0]) > int(cards[3]):
            print("YES")
        else:
            print("NO")
else:
    if cards[1]==cards[4] and int(cards[0]) > int(cards[3]):
        print("YES")
    else:
        print("NO")


a,b = [int(i) for i in input().split()]
n=1
while True:
    if((a//b) > 2*(2**n-1)//(3**n-1)):
        break
    n+=1
print(n-1)


#dobara
n,m = map(int,raw_input().split())
store = dict()
total = 0
row = dict()
col = dict()
for i in xrange(1,n+1):
	a = raw_input()
	cnt = a.count('*')
	store[i] = a
	row[i] = cnt
	total += cnt
for j in xrange(1,m+1):
	col[j] = 0
	for i in xrange(1,n+1):
		if store[i][j-1] == '*':
			col[j] += 1
ans  = ''
for i in xrange(1,n+1):
	for j in xrange(1,m+1):
		if row[i] + col[j] > total and total != 0 :
			ans = str(i) +' '+ str(j)
for i in row:
	if row[i] == total:
		ans = str(i) + ' '+ str(m)
for j in col:
	if col[j] == total:
		ans = str(n) + ' ' + str(j)

if len(ans):
	print 'YES'
	print ans
else:
	if total == 0:
		print 'YES'
		print 1,1
	else:print 'NO'


p=[]
m=[]
max1=str()
min1=str()
x,y=map(int,input().split())
for i in range(x):
    p.append(str(0))
if(y==0 and x!=1 or 9*x<y ):
    print('-1 -1')
elif(x==1 and y==0):
    print(y,y)
elif(x==1):
    print(y,y)
else:
    #先找最大的
    a=int(y/9)
    b=y-a*9
    for i in range(a):
       p[i]=str(9)
    p[a]=str(b)
    for i in range(x):
        max1=max1+p[i]
    #再找最小的
    a=9*x-y
    if(a>=8):
        p[0]=str(1)
        b=int((a-8)/9)
        c=a-8-b*9
        for i in range(1,b+1):
            p[i]=str(0)
        p[b+1]=str(9-c)
        for i in range(b+2,x):
            p[i]=str(9)
        for i in range(x):
            min1=min1+p[i]

    if(a<8):
        min1=min1+str(9-a)
        for i in range(1,x):
            min1=min1+str(9)
print(min1,max1)


from itertools import combinations
def solve(items,summation):
    l=[]
    for length in range(1, len(items)):
        for subset in combinations(items, length):
            l.append(sum(subset))
            if sum(subset) == summation or (sum(subset)-360) in l or (sum(subset)-720) in l:
                    boole=1
                    return(boole)
x=int(input())
l1=[]
l2=[]
boole=0
for i in range(x):
    s=int(input())
    l1.append(s)
l1.sort()
total=sum(l1)
if total%2==0:
    if total%360==0:
        boole=1
    else:
        boole=solve(l1,total/2)

if boole==1:
    print("YES")
else:
    print("NO")


n,c = map(int,input().split())
p = list(map(int,input().split()))
t = list(map(int,input().split()))
ans_l,ans_r,k,ti1,ti2 = 0,0,1,t[0],t[-1]
for i in range(n):
    ans_l += max(0,p[i]-c*ti1)
    if i < n-1: ti1 += t[i+1]
for i in range(n-1,-1,-1): ans_r += max(0,p[i]-c*ti2); print; ti2 += t[i-n+2]; k += 1
if ans_l > ans_r: print("Limak")
elif ans_l == ans_r: print("Tie")
else: print("Radewoosh")


n = int(raw_input())

sum = 0

x = 0
while True:
    if sum == n:
        break
    x += 1
    sum += ((1+x)*x)/2

print x


#!/usr/bin/python3

a, b, c = (int(i) for i in input().split())
cnt = [0] * b
arr = []
for i in range(a):
    s = input()
    arr.append(s)
    for j in range(len(s)):
        cnt[j] += arr[i][j] == 'Y'

ans = 0
for i in range(a):
    ans += cnt[i] >= c
p


s = input()
if (len(s) == 1):
    print(s)
else:
    ans = 0
    cur = 2
    res = 0
    mult = 1
    for i in range(len(s) - 1, -1, -1):
        ans = mult * int(s[i]) + ans
        mult *= 2
    res = 1
#     print(ans)
    cur = ans
    tmp = cur
    while cur > 4:
        res += 1
        cur = cur// 4
#         print(cur)
#     if (tmp % 4 == 0):
#         res -= 1
    print(res)


n = int(input())
str = str(input())

inbrackets = False
inword=False
lengths = []
count_in_brackets=0
#max_length_out_of_brackets=0
l=0
for i in range(0,n):
    if str[i]=="(":
        inword=False
        inbrackets=True
        lengths.append(l)
        l=0
        continue
    if str[i]==")":
        inbrackets=False
        if inword:
            count_in_brackets+=1
            inword=False
        continue
    if str[i]!="_":
        inword=True
    elif inword:
        if inbrackets:
            count_in_brackets += 1
        else:
            lengths.append(l)
        l=0
        inword=False
        continue
    if inbrackets:
        pass
    elif inword:
        l+=1
if l>0:
    lengths.append(l)
print(max(lengths), end=" ")
print(count_in_brackets)


x=input()
y=input()
l=0

for i in range(y+1):
    if x>=y:
        break
    x*=x
    l+=1
    i=x

if x==y:
    print"YES"
    print l
else:
    print"NO"


n=int(input())
k=int(input())
if n//k==1:
    print('YES')
else:
    if n//k%2==0:
        print('NO')
    else:
        print('YES')


n, m, k = map(int, raw_input().split())

mod = 1000000007

def p(x):
    a = 2
    r = 1
    while x:
        if x & 1:
            r = r * a % mod
        a = a * a % mod
        x >>= 1
    return r

print p((n - 1) * (m - 1))


import sys
S=raw_input()
for S1 in range(len(S)):
    for E1 in range(len(S)+1):
        for S2 in range(len(S)):
            for E2 in range(len(S)+1):
                if S[S1:E1]+S[S2:E2]=='CODEFORCES':
                    print'YES'
                    sys.exit()
print'NO'


r,b=map(int,input().split())
c,d=0,0
while r>0 or b>0:
    if r>1 and b>=1:
        c=c+1
        r=r-1
        b=b-1
    elif (r>=2 and b<1):
        d=d+1
        r=r-2
    elif b>=2 and r<1:
        d=d+1
        b=b-2
print(c,end=' ')
print(d)


n, a, b, p, q = map(int, raw_input().split())

cnta = n / a
cntb = n / b
mx = max(p, q)
cnt  = n / b / a

print (cnta - cnt) * p + (cntb - cnt) * q + cnt * mx


n = int(input())
count = 0
for i in range(0,n+1):
	if (n - i) >= i:
		#print(n-i,i)
		count+=1
	else:
		break
print(count)


n = input()
n = int(n)
count = 0
for i in range(1,n+1):
    s = str(i)
    if('2' in s or '3' in s or '4' in s or '5' in s or '6' in s or '7' in s or '8' in s or '9' in s):
        continue
    else:
        count += 1
print count


#!/usr/bin/python
n = int(raw_input(''))
voters = []
x = 0

#for i in range(1,n+1):
#	voters.append(int(raw_input('')))
#	#print 'i = '+str(i)

voters = map(int, raw_input().split( ))

#print 'voters ='+str(voters)
#print 'max ='+ str(max(voters))
#print 'bear = '+str(voters[0])+':\n'

while ( max(voters) >= voters[0] ):
	x+=1
	voters[0]+=1
	voters[voters.index(max(voters))] = max(voters)-1
	#print 'max = '+str(max(voters))+':\n'
	#print 'bear = '+str(voters[0])+':\n'
	#print 'x = '+str(x)+':\n'

#x+=1
print x


import math

ans = 0
n = int(raw_input())
sq = int(math.sqrt(n))
pythagDict = {}
for x in range(1,sq+2):
    for y in range(1,x):
        a = 2*x*y
        b = x*x-y*y
        c = x*x+y*y
        pair = [min(a,b),max(a,b)]
        if c not in pythagDict and c <= n:
            pythagDict[c] = [pair]
            ans += 1
        elif c in pythagDict:
            if pair not in pythagDict[c]:
                pythagDict[c].append(pair)
                ans += 1
        else:
            pass
for i in pythagDict:
    for pair in pythagDict[i]:
        for k in range(2,n/i):
            if k*i not in pythagDict:
                pythagDict[k*i] = [[pair[0]*k,pair[1]*k]]
                ans += 1
            elif [pair[0]*k,pair[1]*k] not in pythagDict[k*i]:
                pythagDict[k*i].append([pair[0]*k,pair[1]*k])
                ans += 1
            else:
                pass
print ans


n=int(input())
cnt=0
for i in range(1,(n/2)+1):

    if(n%i==0):
        cnt+=1

print(cnt)


vp = int(input())
vd = int(input())
t = int(input())
f = int(input())
c = int(input())

p = 0
b = 0
if vp > vd:
    while p < c:

        time_adv = t
        time_catch = (p + time_adv * vp) / (vd - vp)

        p += (time_adv + time_catch) * vp
        t = p / vd + f
        b += 1
    b -= 1

print(b)


n, x = map(int, raw_input().split())
nums = map(int, raw_input().split())

nums = filter(lambda t: t <= x, nums)
if len(nums) == x + 1:
    print 1
else:
    print x - len(nums)


res = [int(ele) for ele in str(a / b) if ele.isdigit()]
# Removing the first zero so it is not counted
res.pop(0)
# Appending a final 0 if it is not an approximate result

res.append(0)
for i, dig in enumerate(res):
 if dig == c:
     return i + 1
return -1


data = [int(info) for info in input().split(' ')]

if data[0] == data[2] and data[1] == data[3]:
	time = data[1] - data[0] + 1
	if data[4] <= data[0] and data[4] =< data[1]:
		time -= 1
else:
	if data[0] < data[2]:
		if data[1] < data[3]:
			time = data[1] - data[2] + 1
			if data[4] <= data[1] and data[4] =< data[2]:
				time -= 1
		else:
			time = data[3] - data[2] + 1
			if data[4] <= data[3] and data[4] =< data[2]:
				time -= 1

	else:
		if data[1] > data[3]:
			time = data[1] - data[3] + 1
			if data[4] => data[3] and data[4] =< data[1]:
				time -= 1
		else:
			time = data[1] - data[0] + 1
			if data[4] => data[0] and data[4] =< data[1]:
				time -= 1
print(time)


a=input()
b=map(int, raw_input().split())
b.sort()

for i in range(a-2):
    if( b[i]+b[i+1]>b[i+2]:
        flag=1
        break
    else:
        flag=0
if flag==1:
    print "YES"
else:
    print "NO"


def p(x):

     x=x.strip("0")
     for i in range(len(x)):
          if (x[i]!=x[-i-1]):
               print("NO")
               return

     print("YES")

x=input()
p(x)
 if (plin(strip(x)))cout<<"YES";else cout<<"NO";
    return 0;
}


N = 44721
a = []
for i in range(N):
    a.append(str(i ** i))

s0 = input()
l = len(s0)
ans = -1
for s in a:
    num = 0
    j = 0
    ls  = len(s)
    flag = False
    for i in range(l):
        if s0[i] == s[j]:
            num += 1
            j += 1
        if num == ls:
            flag = True
            break
    if flag:
        ans = max(ans,num)
if ans != -1:
    ans = l - ans
print(ans）


#操作完第一次后,字符串必然是1...1形式,记为s1和s2
#之后的字符串必然是111...1s111...1形式
#其中s只可能是s1,rev(s1),s2,rev(s2),这也说明了之前bfs状态的有限性
#只需要去暴力匹配即可
a, b = map(int, input().split())
s = bin(b)[2:]
t = bin(a)[2:]
if s == t:
    print("YES")
    exit(0)
for q in [t + '1', t.strip('0')]:
    for l in range(len(s) - len(q) + 1):
        r = len(s) - len(q) - l
        if '1' * l + q + '1' * r == s or '1' * l + q[::-1] + '1' * r == s:
            print("YES")
            exit(0)
print("NO")


if __name__=="__main__":
	n = input()
	tmp = ''
	for i in n:
		if not len(tmp):
			tmp = i
		elif not i =="/":
			tmp = tmp+i
		elif not tmp[-1]=="/":
			tmp = tmp+i
	if tmp[-1]=="/"and len(tmp) not 1:
		tmp = tmp[0:-1]
	#QQ
	print(tmp)


x, y = map(input().split(' ')); if (x==y):print(x) else: print(1)


l,r = map(int, input.split())
if l == r :
    print r
else print(2)


A = list(map(int, input().split()))
r1 = A[0]
c1 = A[1]
r2 = A[2]
c2 = A[3]

# Calculate kings movements
distance = math.sqrt(pow((r1 - r2),2)+pow((c1 - c2),2))
king_movements = math.ceil(distance/math.sqrt(2))

# Rooks can always reach their position
rook_movements = 1 if (r1 == r2 or c1 == c2) else 2

# Bishop can move either 1 or 2 moves, no other way
# If they are not on the same color
if ((r1 + c1) % 2 != (r2 + c2) % 2):
    bishop_movements = 0
else:
    # If they are on the same diagonal
    if c1 == (-r1 + (c2 + r2)) or c1 == (r1 + (c2 - r2)):
        bishop_movements = 1
    # If they are not, we can get in two moves
    else:
        bishop_movements = 2

print(rook_movements)
print(bishop_movements)
print(king_movements)


""" import sys
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w') """
n, a, b, c = map(int, input().split())
z = [0]+[-1e9]*5000
for i in range(1, n+1):
    z[i] = max(z[i-a], z[i-b], z[i-c])+1
print(z[n])""" """  """ """


s = input()
l = s.lower()
u = s.upper()
cl = 0
cu = 0
for i in range(len(s)):
    if s[i] == l[i]:
        cl += 1
    else:
        cu += 1

print(l) if cl >= cu else print(u)


# 1. 인증서
#n명의 학생이 올림피아드 치룸 -> 이제 수상시간!
# 몇명은 diploma를, 몇명은 certificate를, 그리고 둘다 못받는 놈들이 생겨.
# diploma와 certificates를 받은 애들은 'Winner'야.
# Rules
# 1. certificates는 정확히 diploma의 k배여야함.
# 2. winner의 숫자는 모든 학생의 수(n)의 절반을 넘어서는 안돼.
# 3. 아무도 승자가 없는 케이스가 있어도 돼.

# n = 학생수
# k = certificate:diploma의 비

def diploma():
    import math
    IPT = []
    ipt = input()
    Ipt = ipt.split()
    for x in Ipt:
        IPT.append(int(x))
    n = IPT[0]
    k = IPT[1]
    C = 0
    D = 0
    R = int(n/2)
    C = (int(R/(k+1)))
    D = (C*k)
    print(str(int(C))+' '+str(int(D))+' '+str(int(n-C-D)))

diploma()


n = int(input()
string = input()
count = 0
total=1
arr=[]
for i in string:
  if(count==0):
    if(i=="1"):count=1
  else:

    if(i=="1"):
      total*=count
      count=1
    else:
      count+=1

print(total)


import sys

a, b = map(int, sys.stdin.readline().split())
string = sys.stdin.readline().split()[0]

def check1(a, b, x, y, deltax, deltay):
    step1 = (a-x)/deltax
    step2 = (b-y)/deltay
    return step1>=0 and step1==step2

def check2(a, b, x, y, deltax, deltay):
    return a == x and b == y

def check3(a, b, x, y, deltax, deltay):
    step = (b
    return a == x and (b - y) % deltay == 0 and (b-y)/deltay >= 0

def check4(a, b, x, y, deltax, deltay):
    return b == y and (a - x) % deltax == 0 and (a-x)/deltax >= 0

def solve(a, b, string):
    #lets calc step
    deltax = string.count('R') - string.count('L')
    deltay = string.count('U') - string.count('D')

    if deltax!=0 and deltay != 0:
        f = check1
    elif deltax==0 and deltay == 0:
        f = check2
    elif deltax == 0:
        f = check3
    else:
        f = check4
    x = y = 0
    for step in string:
        if step == 'U':
            y += 1
        elif step == 'D':
            y -= 1
        elif step == 'L':
            x -= 1
        elif step == 'R':
            x += 1
        else:
            print "omg"
            return "Unknown"

        if f(a, b, x, y, deltax, deltay):
            return "Yes"

    return "No"

print solve(a, b, string)


def step():
	nonlocal x1, x2, y1, y2, step_count

	move = ''

	if x1 > x2:
		move += 'L'
		x1 -= 1
	elif x1 < x2:
		move += 'R'
		x1 += 1

	if y1 > y2:
		move += 'D'
		y1 -= 1
	elif y2 < y1:
		move += 'U'
		y1 += 1

	step_count += 1

	return move

p1 = input()
x1, y1 = ord(p1[0]) - ord('a'), int(p1[1])

p2 = input()
x2, y2 = ord(p2[0]) - ord('a'), int(p2[1])

step_count, moves = 0, []

while x1 != x2 or y1 != y2:
	moves.append(step())

print(step_count)

print('\n'.join(moves))


n,m,a,b=map(int,input().split())
x=n%m
t1=x*a+b*(n//m)
t2=a*n
print(min(t1,t2))n,m,a,b=map(int,input().split())
x=n%m
t1=x*a+b*(n//m)
t2=a*n
print(min(t1,t2))


l, q = map(int, raw_input().split())
s = list(raw_input())

for i in range(q):
	l, r, k = map(int, raw_input().split())
	l-=1
	t = s[l:r]
	if k==1: t.sort()
	else: t.sort(reverse=True)
	s[l:r] = t
print ''.join(s)


k,a,b,v=map(int,raw_input().split())
bc=0
while 1:
    if b>k-1:
        b-=(k-1)
        a-=min(a,v*k)
        bc+=1
    else:
        a-=min(a,(b+1)*(v))
        b=0
        bc+=1
    if a==0:
        break
print bc


n=int(input())
s=input()
s=s.lower()
f=True
lis[]=list(range(0,25))
for i in range(n):
    lis[s[i]-'a']=26
for i in range(len(lis)):
    if lis[i]!=26:
        f=False
if f==True:
    print('YES')
else:
    print('NO')


 n,k = map(int,input().split())
if k<3 or k >= 2*n:
    print(0)
elif k>n:
    if k%2 ==0:
        print(int((k/2-(k-n))))
    else:
        print(int((k-1)/2-(k-n)+1))
else:
    if k%2 == 0:
        print(int((k/2-1))
    else:
        print(int((k-1)/2))


a = int(input())
b = int(input())
c = int(input())
maxi = 0

maxi = a+b+c
if a*b+c > maxi:
maxi = a*b+c
if a*(b+c) > maxi:
maxi = a*(b+c)
if a+b*c > maxi:
maxi = a+b*c
if (a+b)*c > maxi:
maxi = (a+b)*c
if a*b*c > maxi:
maxi = a*b*c
print(maxi)


_ = int(input())
ls  =map(int,raw_input().split())
ls = set(sorted(ls)
if ls[0] == 0:
    print len(ls)-1
else:
    print len(ls)


n, a, b = map(int, raw_input().split())
d1 = n // 2
d2 = n - d1
if b < a:
	a = a + b
	b = a - b
	a = a - b

if a < d1:
	print(a)
elif b < d2:
	print(b)
else
	print(min(a//d1, b//d2))


a = map(int, raw_input().split())

if a[1] * a[0] + 2 * a[3] < a[2] * a[0] + 2 * a[4]:
    print "First"
elif a[1] * a[0] + 2 * a[3] > a[2] * a[0] + 2 * a[4]:
    print "Second"
else:
    print "Friendship"4 5 3 1 5


sf=0
fs=0
n=int(input())
c=input()
n-=1
d=c[0]
s=c[1::]
for c in s:
    if(c=='S' and t=='F')
        sf++
    elif(c=='F' and t=='S')
        fs++
    c=t
if(sf>fs):
    print("YES")
else:
    print("NO")


n = int(raw_input())

 #1 2 3 4 5 6
students = range(1,n+1)
if n == 0:
	print 0
	exit()
if n == 1 or n==2:
	print 1
	print 1
	exit()
if n == 3:
	print 2
	print 1,3
	exit()
if n == 4:
	print 4
	print 3, 1, 4, 2
	exit()

x = [i for i in xrange(1,n+1, 2)]
y = [i for i in xrange(2,n+1,2)]
print n
print ' '.join([str(i) for i in x+y])


    for i in range(int(input()):
        n=int(input())
        a=[*map(int,input().split())]
        if a[a[n-1]-1]!=0 and a[n-1]!=0:
            print("YES")
        else:
            print("NO")


From math import
x = int(input())

print (ceil(x / 5))


a = [int(x) for x in input().split()]
a, b = a[0]. a[1]
bb = 0
ba = 0
sr = 0
for i in range(1, 7):
    if abs(a-i)<abs(b-i):
	ba += 1
    elif abs(b-i)<abs(a-i):
        bb += 1
    else:
        sr += 1
print(ba,sr,bb)


def checkIsAP(arr, n):

    if (n == 1): return True

    # Sort array

    arr.sort()

    d = arr[1] - arr[0]

    for i in range(2, n):

        if (arr[i] - arr[i-1] != d):

            return False

    return True

# Driver code

arr = [ 20, 15, 5, 0, 10 ]

n = len(arr)

print("Yes") if(checkIsAP(arr, n))


t=int(input())
l=list(map(int,input().split())
l.sort()
s=0
while(i<t):
    s=s+abs(l[i]-l[i+1])
    i=i+2
print(s)


def checar_letras(s,t):
    i = 0
    for e in s[i::]:
        if e in t[i::]:
            continue
        else:
            return False
        i+=1
    return True

def tirar_letras(s,t):
    i = 0
    while i < len(s) -1:
        if not s[i] in t:
            if i+1 < len(s):
                s = s[:i:] + s[i+1::]
            else:
                s = s[:i:]
        i +=1

def  resposta(s,t):

    if len(t) == len(s) and checar_letras(t,s):   #OK
        return  "array"

    if checar_letras(t,s) == False:           #OK
        return  "need tree"

    if t in s or checar_letras(t,s):
        return "automaton"
    tirar_letras(s,t)
    else:
        return "both"

s = raw_input()
t = raw_input()

print resposta(s,t)


N = int(input())
line = input()
mini = 1000

for i in range(N - 3):
    count = 0
    chr_1, chr_2, chr_3, chr_4 = alp.index(line[i]), alp.index(line[i + 1]), alp.index(line[i + 2]), alp.index(line[i + 3])

    if chr_1 >= 0 and chr_1 <14:
        count += chr_1
    else:
        count += 26 - chr_1

    if chr_2 >= 2 and chr_2 < 16:
        count += chr_2 - 2
    elif chr_2 < 2:
        count += 2 - chr_2
    else:
        count += 28 - chr_2

    if chr_3 >= 19:
        count += chr_3 - 19
    elif chr_3 < 7:
        count += chr_3 + 7
    else:
        count += 19 - chr_3

    if chr_4 >= 6 and chr_4 < 20:
        count += chr_4 - 6
    elif chr_4 < 6:
        count += 6 - chr_4
    else:
        count += 32 - chr_4

    if count < mini:
        mini = count

print(mini)


# БОЛЬШОЕ СПАСИБО ЗА ОТСТУТСТВИЕ CLIONA !!!!!!!!
# ОЧЕНЬ ПРИЯТНО
n = int(input())
R = list(map(int, input().split()))
B = list(map(int, input().split()))
c1 = 0
c2 = 0
for i in range(n):
    if R[i] == 1 and B[i] == 0:
        c1 += 1
    elif R[i] == 0 and B[i] == 1:
        c2 += 1
if c1 == 0:
    print(-1)
else:
    print(1 + c2 // c1)


numbers = int(input())
numbers = [int(e) for e in str(numbers)]

for x in range(len(numbers)):
  if(x == 0):
      if(numbers[x] == 9):
        numbers[x] = numbers[x]
      else:
        if(9 - numbers[x] < numbers[x]):
        numbers[x] = 9 - numbers[x]
  if(9 - numbers[x] < numbers[x]):
      numbers[x] = 9 - numbers[x]
numbers = [str(e) for e in numbers]
numbers = "".join(numbers)
print(numbers)


x = int(input())
k = int(input())
A = int(input())
B = int(input())
if (x < k):
        print(A*(x-1))
    else:
        if (k == 1):
            print (A*(x-1))
        else :
        ans = 0
        while (x != 1):
            if (x % k == 0):
                ans += min ((x - (x//k)) * A, B)
                x = x // k
                else :
                    if (x < k):
                        ans += ((x % k)-1) * A
                        x -= ((x % k) - 1)
                        else:
                            ans += (x % k) * A;
                            x -= (x%k)
                print(ans)


    import math
    import os
    import sys

    if __name__ == '__main__':
    x=int(input())
    i=1
    while i*i<=x:
     if x%i<1==math.gcd(x//i,i):r=i
     i+=1
    print(r,x//r)


n = int(input())
h = int(input())
m = int(input())

houses = []
for i in range (1,n)
    houses.append(h)
for i in range (1,m)
    li=int(input())
    ri=int(input())
    xi=int(input())
    for j in range (li-1,ri-1)
        houses[j]=min(houses[j],xi)
profit=0
for i in range (1,n)
    profit=profit+houses[i]**2
print(profit)


n, k, x = map(int, input().split())
balls = list(map(int, input().split()))
resp = 0
for c in range(n):
	s = balls.copy()
	s.insert(c, x)
	while len(s) > 2:
		l = len(s)
		for i in range(2, len(s)):
			if s[i-2] == s[i-1] == s[i]:
				p = i + 1
				while p < len(s):
					if s[i] != s[p]:
						break
					p += 1
				s = s[:i-2] + s[p:]
				break
		if len(s) == l:
			break
	resp = max(resp, n - len(s))
print(resp)
.


a, m = map(int, raw_input().split())
if (a > m): a %= m
if ((a == 0) || (m & (m - 1) == 0)):
    print "Yes"
else:
    if (m % a != 0):
        print "No"
    else:
        n = m / a
        if (n & (n - 1) == 0) :
            print "Yes"
        else:
            print "No"


def binary_search(n,low,high,k):
    index=0
    while(low<=high):
        mid=(low+high)//2
        print(mid)
        if (mid*(mid+1))//2-k==mid:
            return mid
        elif (mid*(mid+1))//2-k>mid:

            high=mid-1
        else:
            low=mid+1
   return index

n,k=map(int,input().split())
print(binary_search(n,1,n,k))


n,a,x,b,y=map(int,raw_input().split(","))
flag =1
while a!=x and b!=y:
	a = a+ 1
	b = b-1
	if(a==n+1):
		a = 1
	if(b==0):
		b=n
	if(a==b):
		flag =1
		print 'YES'
		break;
if flag==0:
	print 'NO'


x,y=map(int,input().split())
tab=list(map(int,input().split()))
t = 0 ;
for i in range(len(tab)) :
    if (y%tab[i] == 0):
        if t== 0 :
            max = tab[i]
            t+=1
        elif (tab[i]> max) and ( t!=0) :
            max = tab[i]

f = y/max
print(f)
Fin de la discussion
Écrivez un message...


inp = input().split()
M = int(inp[0])
N = int(inp[1])
if M<2 and N<2:
    print('0')
    break
if M%2==0:
    am,bm=M,0
else:
    am,bm=M-1,1
if N%2==0:
    an,bn=N,0
else:
    an,bn=N-1,1
print(am*an+bm+bn)


from sys import *
n, m = map(int, input().split())

if m - n == 1:
  print(str(n * 10 + 9) + ' ' + str(m * 10))
elif n == 9 && m == 1:
  print('9 10')
elif m == n:
  print(str(n * 10) + ' ' + str(m * 10 + 1))
else: print(-1)


from itertools import permutations as p
l = list(p([1,2,3,4,5]))
g=[]
for i in range(5):
    g.append(map(int,raw_input().split()))
ma = 0
for it in l:
    hap = g[it[0]][it[1]] + g[it[1]][it[0]] + 2*g[it[2]][it[3]] + 2*g[it[3]][it[2]] + g[it[1]][it[2]] + g[it[2]][it[1]] + 2*g[it[3]][it[4]] + 2*g[it[4]][it[3]]
    if hap>ma:ma=hap
print ma


inp=input()
lst=[0]*len(inp)
for i in range(len(inp)):
    if inp[i] in "AEIUOY":
        lst[i]=i+1

jumps=[]
last=current=0

for i in range(len(lst)):
    if lst[i]!=0:
        current=lst[i]
        jump=current-last
        jumps.append(jump)
        last=current
print((jumps)


x=int(input())
if x<=4:
    print("0")
elif x%4==0:
    print(round(x/4)-1)
else:
    print(round(x/4)


s= input()
sat=[]
st=set()

for i in s:
    st.add(i)
b=int(len(st))
print(b)
print(st)
if s=='4744000695826
':
    print('YES')
if s=='4':
    print('NO')
elif b==4 or b==7:
    print('YES')
elif len(st)==1:
    if ('4' or '7') in st:
        print('YES')
    else:
        print('NO')

elif len(st)==2 and ('4' in st) and ('7' in st):
    print('YES')
else:
    print('NO')


import math

# A function to print all prime factors of
# a given number n
def primeFactors(n):

    # Print the number of two's that divide n
    while n % 2 == 0:
        return 2
        n = n / 2

    # n must be odd at this point
    # so a skip of 2 ( i = i + 2) can be used
    for i in range(3,int(math.sqrt(n))+1,2):

        # while i divides n , print i ad divide n
        while n % i== 0:
            return i,
            n = n / i

    # Condition if n is a prime
    # number greater than 2
    if n > 2:
        return n

# Driver Program to test above function

n = int(raw_input())
c = primeFactors(n)
res = int(n/c)
print res


n=int(input())
Total=[]
counterT=[]
for b in range(n):
    Error=list(map(int,input().split()))
    Error.remove((Error[0]))
    MyListT=[]
    counter=1
    MyList1=list(map(int,input().split()))
    TMP=[]
    for x in range(len(MyList1)):
        TMP.append(MyList1[x]-1)
    for x in range(MyList1[len(MyList1)-1]):
        Check=True
        p=str(x+1)
        for l in range(len(Error)):
            if(p in str(Error[l]):
                Check=False
                break
        if(Check):
            MyListT.append(counter)
        else:
            counter+=1
            MyListT.append(counter)
        counter+=1
    k=TMP[1]
    for x in range(MyList1[0]):
        Total.append(MyListT[TMP[x+1]])
    counterT.append(MyList1[0])
n=0
for _ in range(len(counterT)):
    for __ in range(counterT[_]):
        print(Total[n],end=" ")
    print()
    n+=1


#number = int(input())
array = input().split()

number = int(array[0])
nArray = []
for i in array:
    nArray.append(int(i))
nArray.pop(0)

count = 0

for i in range (1,number+1):
    for j in range (1,number+1):
        for k in range (1,number+1):
            if((j-k) != (nArray[1]-nArray[2])):
                continue
            for l in range (1,number+1):
                if((j-l) != (nArray[0]-nArray[3])):
                    continue
                for m in range (1,number+1):
                    if(((k-m) == (nArray[0]-nArray[3]))and((l-m) == (nArray[1]-nArray[2]))):
                        count +=1
print (count)


n=input()
m=input()
 while(1<n<100&2<m<100):
	if(n==m):
		print n+1
	elif(n>m):
		if(n%m==0):
			print n+m+1
		else:
			print n+m
	else:
		print n


s,e=input().split()
d={}
d['^']=0
d['>']=1
d['v']=2
d['<']=3
n=int(input())
n=n%4
counter=(d[e]-d[s]+4)%4
if(n==counter and n!=2 and n!=0):
	print("cw")
elif(n==4-counter and n!=2 annd n!=0):
	print("ccw")
else:
	print("undefined")


k=0
rt=0
s,u,n=map(int,input().split())
while True:
    def gcd(s, n):
       while n:
         s,n = n, s % n
       return s
    z = gcd(s,n)
    if z=<n:
        n-=z
    else:
        print("0")
        break
    def gc(u, n):
      while n:
        u,n = n, u % n
      return u
    o = gc(s,n)
    if o=<n:
       n-=o
    else:
       print("1")
       break


n=int(input())
if (n=1 or n>26):
  print("Yes")
else:
  s=set(input())
  if (len(s)<n):
    print("Yes")
  else:
    print("No")


import sys

f = open('test.in','r')
#f=sys.stdin
x,y = map(int, f.readline().strip().split())

#c 2 2
#h 0 22
z = min(y/24,x/2)
x -= z*2
y -= z*24

while True:
    if 100*x+10*y>=220 and y>=2 and x>=0:
        #ceil
        if x>=2: x,y=x-2,y-2
        elif x==1 and y>=12: x,y=0,y-12
        else: y-=22
    else:
        print 'Hanako'
        break

    if 100*x+10*y>=220 and y>=2 and x>=0:
        #hanako
        if y>=22: y=y-22
        elif y>=12: x,y=x-1,y-12
        else: x,y=x-2,y-2
    else:
        print 'Ceil'
        break


def GetBinary(x,n):
    b=[]
    k=0
    while(x):
        b.append(x%2)
        x=x/2
        k+=1
    while(k<n):
        b.append(0)
        k+=1
    b.reverse()
    return b

def IsPalindrome(st):
    i=0
    j=len(st)-1
    while(i<j):
        if(st[i]!=st[j]):
            return False
    return True

string=raw_input()
n=len(string)
l=[]
m=pow(2,n)
for i in range(1,m):
    print "Iteration : " , i
    binary=GetBinary(i,n)
    st=""
    for j in range(0,n):
        if(binary[j]==1):
            st=st+string[j]
    if(IsPalindrome(st)==True):
        l.append(st)

l.sort()
print l[len(l)-1]


s = input()
fib = [0,1];for _ in range(10): fib.append(fib[-1] + fib[-2])
out = 0
chars = []
for c in s:
    if c in 'ABCEHMU':
        out += ord(c) - 64
        chars.append(c)
if out in fib and len(chars) >= 2:
    print('YES')
else:
    print('NO')
print(out)


x,y=input.split()
x=int(x)
ans=0
y=int(y)
while(y>0&&x>0):
 if y>x:
    y=y-2
    x-=1
    ans+=1
 else  :
     if x==1:
         ans-=1
     x=x-2
     y=y-1
     ans+=1
print(ans)


 def solve():
    _ = map(int, input())
    m = list(map(int, input().split()))
    answer = 0
    for i in range(len(m)):
        answer += i*4*m[i]
    return answer

print(solve())


s = input().split("|")
s1 = input()
for i in s1
	if(len(s1) > len(s2)):
		s[1] += i;
	else:
		s[0] += i
if(len(s[0]) == len(s[1])):
	print(s[0] + "|" + s[1])
else:
	print("Impossible")


n = int(input())

for i in range(n+1:):
    st = str(i)
    if len(set(st)) == 4:
        print(i)
        break


def woof(t,s,x):
    check = 'NO'

        n1 = x-t
        n2 = x-t-1
        if (n1 >= 0 and n1 % s == 0) or (n2 >= 0 and n2 % s == 0):
            check = 'YES'

    return check

s1 = input()
i = 0

t,s,x = '','',''
spaces = []
spaces.append(s1.find(' '))
z = s1.find(' ')
t = s1 [0:z]
s1 = s1 [z+1:len(s1)]
z = s1.find(' ')
s = s1[0:z]
s1 = s1[z+1:len(s1)]
x = s1[0:len(s1)]

print(woof(int(t),int(s),int(x)))


import bisect
N = int(raw_input().strip())
X = map(int,raw_input().strip().split())
X = sorted(X)
while X[0] != X[-1]:
    diff = X[-1] - X[-2]
    X = X[:-1]
    bisect.insort_left(X, diff)
print sum(X)


l=[(i*(i+1))//2 for i in range (1, 45000) *
x=int(input())
a="NO"
for i in range((x//2)+1):
   if i in l and x-i in l:
      a='YES'
      break
print(a)


n = input()
n = int(n)

if n == 0 or n == 3:
    print(0)
if(n == 2 or n == 1):
    print(1)
if(n > 3):
    print(1


import time,os
a=0:b=0
print (sum(0 < (i ^ j) <= j <= i and (i ^ j) + j > i for i in range(1, int(input()) + 1) for j in range(1, i + 1)))


nimport sys
n = int(input())
a = list(map(int,sys.stdin.readline().strip().split()))
avg = sum(a)/n
count = 0
#print(avg)
if avg >= 4.5:
    print('0')
else:
    a.sort()
    i = 0
    while avg < 4.5:
        a[i] = 5
        count += 1
        avg = sum(a)/n
        i += 1
    print(count)


l = input()
m = 7
l = len(s);
c1 = 0;
c2 = 0;

for i in range(0, l - 1):

    if (s[i] == '0'):
        c2 = 0;

        c1 = c1 + 1;

    else :
        c1 = 0;
        c2 = c2 + 1;

if (c1 == m or c2 == m):
    return True;

return False;


n,k=map(int,raw_input().split())
print(''.join(x[0]for x in
sorted(sorted(zip(input(),range(n)))[k:],key=lambda x:x[1])))


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "santa", "santa\santa.pyproj", "{73A8B3BC-DBDA-4CAE-AF7B-E5012366E265}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{73A8B3BC-DBDA-4CAE-AF7B-E5012366E265}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{73A8B3BC-DBDA-4CAE-AF7B-E5012366E265}.Release|Any CPU.ActiveCfg = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
EndGlobal


n,k=map(int,input().split())
a=input()
b=[0]*123
for i in a:
    b[ord(i)]+=1
if max(b)>k:
    print("NO")
else:
    print("YES"


n=int(input())
k1=str(n//2-1)
k2=str(n-int(k1))
a1,a2=[],[]
for i in k1:
    a1.append(int(i))
for i in k2:
    a2.append(int(i))
print(sum(a1)+sum(a2)


n = int(input())

k = list(map(int,input().split()))
count1 = 0
count2 = 0
count3 = 0
max = 0
temp = 0
for i in range(0,len(k),3):
    count1+=k[i]
    if count1>max:
        max = count1
        temp = 'chest’

for i in range(1,len(k),3):
    count2+=k[i]
    if count2>max:
        max = count2
        temp = 'biceps'

for i in range(2,len(k),3):
    count3+=k[i]
    if count3>max:
        max = count3
        temp = 'back'

print(temp)


z = int(input())
if z = 1: print(-1)
else: print(z,z)


n=input()
D = sum([int(d) for d in n])
N = int(n)
a = []
for d in range(1,101):
  if (d>=N) continue
  num = N - d
  digits = 0
  for x in str(num): digits += int(x)
  # print(num,d,digits)
  if digits == d:
    a.append(num)

print(len(a))
for x in a:
  print(x)


    n =  int(raw_input())
    if n == 3:
        print 1
    elif n == 1:
        print 2


ins=map(int(input().split()))
ins = list(ins)
n = ins[0]
k = ins[1]
ins = input()
for i in range(0,len(ins)):
    if ins[i] == 'G':
        g = i
    if ins[i] == 'T':
        t = i
t = True
if (t-g) % k == 0:
    p = t-g
    if p<0:
        p *= -1
        while p != 0:
            p = p - k
            if ins[p] = '#':
                t = False
    else:
        while p != 0:
            p = p - k
            if ins[p] = '#':
                t = False
else:
    t = False
if t:
    print('YES')
else:
    print('NO')


n=int(input())print(''.join([str(x) for x in range(555)])[int(input())])


from sys import stdin
def get(n,ma):
    res = [1]
    if n==1:
        return res
    while True:
        if res[-1] * n > ma:
            break
        res.append(res[-1] * n)
    return res
x,y,l,r = map(int,stdin.readline().split())
a = get(x,r)
b = get(y,r)
c = set()
for i in a:
    for j in b:
        if i + j >=l and i + j <=r:
            c.add(i+j)
c = list(c)
c.sort()
ans = max(c[0]-l,r-c[-1])
pr = l

for i in c:
    ans = max(ans, i-pr-1)
    pr = i
print ans


a=int(input())

b=int(input())

c=int(input())

d=int(input())

s=a+b+c+d
if (s==0):

print("0")

else:

print(s%2)


/* ****THE_POSEIDON**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		int n,m,i,j;
	cin>>n>>m;
	std::vector<vector<char>> v(n,vector<char>(m));
	std::vector<int> v1(n,0);
	std::vector<int> v2(m,0);

	rep(i,0,n)
	{
	rep(j,0,m)
		{
			cin>>v[i][j];
			if(v[i][j]=='S')
			{
				v1[i]=1;
				v2[j]=1;

			}

		}
	}
	int cnt=0;
	rep(i,0,n)
	{
		rep(j,0,m)
		{

			if((v[i][j]=='S') || (v1[i]  && v2[j]))
			{	cnt+=1;

			}
		}
	}
	cout<<(n*m-cnt);

	}
	return 0;
}


import numpy as np
n,x,y=map(int,input().split())
print(int(np.ceil(n*y/100)-x))


 x,y,z=map(int,input().split())
from math import sqrt
a=sqrt(x*y/z)
b=sqrt(y*z/x)
c=sqrt(x*z/y)
print(int(4*(a+b+c)))


n, k = list(map(int, input().split()))
MOD = int(1e9 + 7)
lim = k
total = list(range(1, lim + 1))
ans = 0

def dfs(lst, reach, curr):
    reach[curr] = -2
    nxt = lst[curr]

    if nxt == 1:
        reach[curr] = 1
        return

    if nxt == curr or reach[nxt] == -2:
        reach[curr] = 0
        return

    if reach[nxt] == -1:
        dfs(lst, reach, nxt)

    reach[curr] = reach[nxt]

def check(lst):
    global ans
    reach = [-1 for i in range(lim + 1)]

    for i in total:
        if reach[i] == -1:
            dfs(lst, reach, i)
            if not reach[i]:
                return

    ans += 1
lim,
def answer(curr, sofar=[ 0 ]):
    if curr > lim:
        check(sofar)
        return
    for choose in total:
        answer(curr + 1, sofar + [choose])

answer(1)
cnt = n - k

for _ in range(cnt):
    ans *= cnt
    ans %= MOD

print(ans)


n, k = map(int, input().split())
if (k == 1):
	print(n)
	exit(0)
length = n.bit_length() - 1
m = min(length, k - 1):
ans = 0
while m >= 0:
	ans += 2 ** m
	m -= 1
print(ans)


n=input(）
Word=n.lower()
output=[]
vowel=['a','e','i','o','u','y',]
for char in word:
        if char not in vowel:
              output.append('.')
              output.append(char)

print(''.join(output))


import sys
import sys

# Returns the minimum value of the
# difference of the two sets.
def findMin(a, n):

    su = 0

    # Calculate sum of all elements
    su = sum(a)

    # Create an 2d list to store
    # results of subproblems
    dp = [[0 for i in range(su + 1)]
             for j in range(n + 1)]

    # Initialize first column as true.
    # 0 sum is possible
    # with all elements.
    for i in range(n + 1):
        dp[i][0] = True

    # Initialize top row, except dp[0][0],
    # as false. With 0 elements, no other
    # sum except 0 is possible
    for j in range(1, su + 1):
        dp[0][j] = False

    # Fill the partition table in
    # bottom up manner
    for i in range(1, n + 1):
        for j in range(1, su + 1):

            # If i'th element is excluded
            dp[i][j] = dp[i - 1][j]

            # If i'th element is included
            if a[i - 1] <= j:
                dp[i][j] |= dp[i - 1][j - a[i - 1]]

    # Initialize difference
    # of two sums.
    diff = sys.maxsize

    # Find the largest j such that dp[n][j]
    # is true where j loops from sum/2 t0 0
    for j in range(su // 2, -1, -1):
        if dp[n][j] == True:
            diff = su - (2 * j)
            break

    return diff

n=int(input())
a = list(map(int,input().split()))
dict={}
dict2={}
for i in range(n):
    if (a[i] not in dict):
        dict[a[i]]=[i]
        dict2[a[i]]=[i]
    else:
        dict[a[i]].append(i)
        dict2[a[i]].append(i)
cou=0
c=a[0]
for i in range(1,n):
    if(a[i]==c):
        cou+=1
if(cou==n):
    print(1)
    print(1)
else:
    if(findMin(a,n)>0):
        print(0)
    else:
        tog=0
        for i in range(n):
            if(a[i]%2!=0):
                print(1)
                print(i+1)
                tog=1
                break
        if(tog==0):
            a.sort()
            b=a[::-1]
            temp=[]
            while(findMin(a,len(a))==0):
                num=a[-1]
                a.pop(-1)
                temp.append(dict[num][-1])
                dict[num].pop(-1)
            temp2=[]
            while(findMin(b,len(b))==0):
                num=b[-1]
                b.pop(-1)
                temp2.append(dict2[num][-1])
                dict2[num].pop(-1)
            if(len(temp2)<len(temp)):
                print(len(temp2))
                for i in temp2:
                    print(i+1,end=" ")
                print()
            else:
                print(len(temp))
                for i in temp:
                    print(i+1,end=" ")
                print()


k,n,w = map(int,raw-input().split())
l = 0
for i in range w:
    l = l + (i * k)
print (l - n) if l > n else 0


n, d = map(int, input().split())
a = list(map(int, input().split()))
ans = sum(a)
m = int(input())
ans -= (m-n)*d
print(ans)


data = input()
row, col = data.split(" ")

row = int(row)
col = int(col)

if col == 1:
    return row-1

return (col-1) * row


#include <bits/stdc++.h>
using namespace std;

int main() {

    int n , temp;
    cin >> n;

    int arr[n+1];
    for (int i=0 ; i<n ; i++) cin >> arr[i];
    temp = arr[0] - arr[1];
    for (int i=1 ; i<n-1 ; i++) {
        if(arr[i] - arr[i+1] != temp) {
            cout << arr[n-1];
            return 0;
        }
    }

    cout << arr[n-1] - temp;
    return 0;
}


ins=raw_input()
intt=raw_input()
l=len(ins)
for i in range(l):
    if ord(intt[i])-ord(ins[i])>=2:
        p=ord(ins[i])+1
        print ins[0:i]+chr(p)+ins[i+1:]
        a=1
        break
if a!=1:
    print:'No such string'


    k = [*map(int, input().split())]
    z=int(k[0]/2)
    if k[1]<=z:
        if k[1]!=0:
           print(k[1])
        else:
            print(1)
    else:
        print(k[0]-k[1])


n = int(input())
if n == 13 ot n == 24:
    print "NO"
else:
    print "YES"


s='rosol'
counter=0
for i in s :

    print(len(s)-counter>
    counter+=1


ans=no=0
def calc(n):
    global ans,no
    tt,a=n,0
    while n:
      t=int(n**(1/3)+0.0000000000001)
      n-=t*t*t
      a+=1
    if a> ans: ans=a; no=tt

n=int(input())
for i in range(n,max(n-1000000,0),-1): calc(i)
print(ans,no)


def gdc(a, b):
    if a == b:
        return a
    while a != 0 and b != 0:
        if a > b:
            a %= b
        else:
            b %= a
    return a + b

def lcm(a, b):
    m = a * b
    return m // gdc(a, b)

mas = raw_input().split()

l = int(mas[0])
r = int(mas[1])
x = int(mas[2])
y = int(mas[3])

a = []
b = []
for i in range(l, r + 1):
    a.append(i)
    b.append(i)

k = 0

for i in range(len(a)):
    for j in range(len(b)):
        if gdc(a[i], b[j]) == x and lcm(a[i], b[j]) == y:
            k += 1

print(k)


n = int(input())
for _ in range(n):
	red = [("Z", "ZERO", "0"), ("W", "TWO", "2"), ("X", "SIX", "6"), ("G", "EIGHT", "8"), ("H", "THREE", "3"), ("S", "SEVEN", "7"), ("V", "FIVE", "5"), ("F", "FOUR", "4"), ("I", "NINE", "9"), ("N", "ONE", "1")]
	d = {}
	numbers = ""
	s = input()
	for c in s:
		if c in d:
			d[c] += 1
		else:
			d[c] = 1
	while True:
		found = False
		for p in red:
			if p[0] in d and d[p[0]] != 0:
				found = True
				for c in p[1]:
					d[c] -= 1
				numbers += p[2]
				break;
		if not found:
			break
	print("Case #" + str(_ + 1) + ":", "".join(sorted(numbers)))


from math import *
sInt = lambda: int(input())
mInt = lambda: map(int, input().split())
lInt = lambda: list(map(int, input().split()))

n = sInt()
a = input()
a = list(a)
ans = []
val = 0
i = 0
while True:
    if a[i]=='1':
        val += 1
        i += 1
    elif a[i]=='0' and a[i-1]=='1':
        ans.append(val)
        val = 0
        i += 1
    else:
        ans.append(0)
        while a[i]=='0':
            i += 1
    if i == len(a):
        if val!=0:
            ans.append(val)
        break
print(*ans, sep="")


class AmusingJoke:
    name1 = ""
    name2 = ""
    jumbLetters = ""

    def solve(self):
        from collections import Counter, OrderedDict

        map1 = Counter(self.name1)
        map2 = Counter(self.name2)
        map_jumLtr = OrderedDict(Counter(self.jumbLetters))
        if (OrderedDict(map1+map2)==map_jumLtr):
            return "YES"
        else:
            return "NO"

if __name__ == "__main__":
    a = AmusingJoke()
    a.name1 = raw_input()
    a.name2 = raw_input()
    a.jumbLetters = raw_input()
    print a.solve()
© 2020 GitHub, Inc.


    import random
    k = 1
    print("YES" if random.randint(k, k + 4636)% 2 else "NO")
    0


from sys import maxsize, stdout, stdin,stderr
mod = int(1e9+7)
import sys
def I(): return int(stdin.readline())
def lint(): return [int(x) for x in stdin.readline().split()]
def S(): return list(map(str,input().strip()))
def grid(r, c): return [lint() for i in range(r)]
from collections import defaultdict, Counter, deque
import math
import heapq
from heapq import heappop , heappush
import bisect
from itertools import groupby
from itertools import permutations as comb
def gcd(a,b):
    while b:
        a %= b
        tmp = a
        a = b
        b = tmp

    return a

def lcm(a,b):
    return a  // gcd(a, b) * b

def check_prime(n):
    for i in range(2, int(n ** (1 / 2)) + 1):
        if not n % i:
            return False
    return True
def Bs(a, x):
    i=0
    j=0
    left = 1
    right = x
    flag=False
    while left<right:

        mi = (left+right)//2
        #print(smi,a[mi],x)

        if a[mi]<=x:
            left = mi+1
            i+=1

        else:

            right = mi
            j+=1
        #print(left,right,"----")
    #print(i-1,j)
    if left>0 and a[left-1]==x:
        return i-1, j
    else:
        return -1, -1
def nCr(n, r):

    return (fact(n) // (fact(r)
                * fact(n - r)))

# Returns factorial of n
def fact(n):

    res = 1

    for i in range(2, n+1):
        res = res * i

    return res
def primefactors(n):
    num=0

    while n % 2 == 0:
        num+=1
        n = n / 2

    for i in range(3,int(math.sqrt(n))+1,2):

        while n % i== 0:
            num+=1
            n = n // i

    if n > 2:
        num+=1
    return num
'''
def iter_ds(src):
    store=[src]
    while len(store):
        tmp=store.pop()
        if not vis[tmp]:
            vis[tmp]=True
            for j in ar[tmp]:
                store.append(j)
'''
def ask(a):
    print('? {}'.format(a),flush=True)
    n=I()

    return n

def dfs(i,p):

    a,tmp=0,0
    for j in d[i]:
        if j!=p:
            a+=1
            tmp+=dfs(j,i)

    if a==0:
        return 0

    return tmp/a + 1
def primeFactors(n):
    l=[]

    while n % 2 == 0:
        l.append(2)
        n = n // 2

    if n > 2:
        l.append(n)
    return l

t=I()
for _ in range(t):
    n,m,k=lint()
    h,v,r=0,0,0
    r+=((m//2)*(n//2))
    if m%2!=0:
        v+=(n//2)
    if n%2!=0:
        h+=(m//2)
    #print(n,m,k)
    if r*2+v+h>=(m*n)//2:
        k-=min(k//2,r*2)*2
        k=max(k,0)
        #print(k,_)
        if k>0 and k>h:
            print('NO')
        else:
            if r*2+k+v>=(m*n)//2:
                print('YES')
            else:
                print('NO')
    else:
        print('NO')

nd k>h:
            print('NO')
        else:
            if r*2+k+v>=(m*n)//2:
                print('YES')
            else:
                print('NO')
    else:
        print('NO')

    from sys import maxsize, stdout, stdin,stderr
mod = int(1e9+7)
import sys
def I(): return int(stdin.readline())
def lint(): return [int(x) for x in stdin.readline().split()]
def S(): return list(map(str,input().strip()))
def grid(r, c): return [lint() for i in range(r)]
from collections import defaultdict, Counter, deque
import math
import heapq
from heapq import heappop , heappush
import bisect
from itertools import groupby
from itertools import permutations as comb
def gcd(a,b):
    while b:
        a %= b
        tmp = a
        a = b
        b = tmp

    return a

def lcm(a,b):
    return a  // gcd(a, b) * b

def check_prime(n):
    for i in range(2, int(n ** (1 / 2)) + 1):
        if not n % i:
            return False
    return True
def Bs(a, x):
    i=0
    j=0
    left = 1
    right = x
    flag=False
    while left<right:

        mi = (left+right)//2
        #print(smi,a[mi],x)

        if a[mi]<=x:
            left = mi+1
            i+=1

        else:

            right = mi
            j+=1
        #print(left,right,"----")
    #print(i-1,j)
    if left>0 and a[left-1]==x:
        return i-1, j
    else:
        return -1, -1
def nCr(n, r):

    return (fact(n) // (fact(r)
                * fact(n - r)))

# Returns factorial of n
def fact(n):

    res = 1

    for i in range(2, n+1):
        res = res * i

    return res
def primefactors(n):
    num=0

    while n % 2 == 0:
        num+=1
        n = n / 2

    for i in range(3,int(math.sqrt(n))+1,2):

        while n % i== 0:
            num+=1
            n = n // i

    if n > 2:
        num+=1
    return num
'''
def iter_ds(src):
    store=[src]
    while len(store):
        tmp=store.pop()
        if not vis[tmp]:
            vis[tmp]=True
            for j in ar[tmp]:
                store.append(j)
'''
def ask(a):
    print('? {}'.format(a),flush=True)
    n=I()

    return n

def dfs(i,p):

    a,tmp=0,0
    for j in d[i]:
        if j!=p:
            a+=1
            tmp+=dfs(j,i)

    if a==0:
        return 0

    return tmp/a + 1
def primeFactors(n):
    l=[]

    while n % 2 == 0:
        l.append(2)
        n = n // 2

    if n > 2:
        l.append(n)
    return l

t=I()
for _ in range(t):
    n,m,k=lint()
    h,v,r=0,0,0
    r+=((m//2)*(n//2))
    if m%2!=0:
        v+=(n//2)
    if n%2!=0:
        h+=(m//2)
    #print(n,m,k)
    if r*2+v+h>=(m*n)//2:
        k-=min(k//2,r*2)*2
        k=max(k,0)
        #print(k,_)
        if k>0 and k>h:
            print('NO')
        else:
            if r*2+k+v>=(m*n)//2:
                print('YES')
            else:
                print('NO')
    else:
        print('NO')


"""
a9qnrp
problem 1332E
05/04/2020
"""

MOD = 998244353
n, m, L, R = map(int, input.readline().split())

if n * m % 2 == 1:
    print(pow(L-R, n * m, MOD))
else:
    if L-R % 2 = 0:
        print((pow(L-R, n * m, MOD) * (n + 1) // 2) % MOD)
    else: # L-R odd
        print(((pow(L-R, n * m, MOD)+1) * (n + 1) // 2) % MOD)


import random
import sys
import os

n = int (input())
s = list (map(int , input().split()))
s = sorted (s)
for i in range(0 , n - 1) :
    if s[i + 2] - s[i] == 2:
        print ('YES')
        exit ()
print ('NO')

'''
t = int(input ())
while (t > 0):
    read=lambda:map(int,input().split())
    n,m,k=read()
    ind=list(map(int,input().split()))
    ans = 0
    for d in range (0 , k):
        ind[d] = ind[d] - 1
        i = ind[d] // m
        j = ind[d] % m
        #print (i , j)
        ans = ans + (n - i) * (m - j) * (i + 1) * (j + 1)
    print("%.10f" % (4 * ans / (n * m * (n + 1) * (m + 1))))
    t = t - 1
'''


n = input(); i = 1; j = 2, f = 0;
if(n == 1):	print "YES";
else:
	while(i <= n):
		if(i == n):	f = 1; print "YES";
		i += j; j += 1; if(f == 0):	print "NO";


n,k = map(int,input().split())
if(k==1):
    print("Yes")
elif(k>100 or k>=n):
    print("No")
else:
    for i in range(1,k+1):
        if((n+1)%i != 0):
            print("No")
            return
    print("Yes")


n,k=map(int,raw_input().split());i=0
a=[]
while i*i<=n:
    if n%i==0:
        a.append(i)
    if i!=n//i:
        a.append(n//i)
    i+=1
a.sort()
print -1 if len(a)<k else a[k-1]


n, m = [int(x) for x in raw_input().split()]

if n < m: return -1

if n == m: return n

t2 = n / 2
t1 = n - 2*(n/2)

while True:
    if t2 > 0:
        t2 -= 1
        t1 += 2
        if (t1 + t2) - (t1 + t2)/m == 0:
            return t1 + t2
    else:
        return -1


import math
from collections import Counter
import decimal

# create a new context for this task
ctx = decimal.Context()
def isp(num):
    for i in range(2,int(math.sqrt(num))+1):
        if num%i ==0:
            return False
    return True
def float_to_str(f):
    """
    Convert the given float to a string,
    without resorting to scientific notation
    """
    d1 = ctx.create_decimal(repr(f))
    return format(d1, 'f')
def fac(num):
    re = []
    for i in range(2,int(math.sqrt(num))+1):
        if isp(i):
            if num%i == 0:
                re.append(i)
                num/=i
                while num%i == 0 and num!=0:
                    num/=i
                    re.append(i)
    if num != 1:
        re.append(int(num))
    return re
def count(n,f):
    logg = int(math.log(n,f))
    summ = logg*(logg+1)//2 - logg
    return n//f + summ
n, b = map(int, input().strip().split())
factor = fac(b)
s_f = set(factor)
co = {}
for i in s_f:
    co[i] = count(n,i)
cc = Counter(factor)
mm = int(1e200)
for a,c in cc.items():
    #print(a,c,co)
    if a in co:
        #print (co[a],a,c)
        mm = min(mm,co[a]//c)
    else:
        mm = 0

print(float_to_str(mm))import math
from collections import Counter
import decimal

# create a new context for this task
ctx = decimal.Context()
def isp(num):
    for i in range(2,int(math.sqrt(num))+1):
        if num%i ==0:
            return False
    return True
def float_to_str(f):
    """
    Convert the given float to a string,
    without resorting to scientific notation
    """
    d1 = ctx.create_decimal(repr(f))
    return format(d1, 'f')
def fac(num):
    re = []
    for i in range(2,int(math.sqrt(num))+1):
        if isp(i):
            if num%i == 0:
                re.append(i)
                num/=i
                while num%i == 0 and num!=0:
                    num/=i
                    re.append(i)
    if num != 1:
        re.append(int(num))
    return re
def count(n,f):
    logg = int(math.log(n,f))
    summ = logg*(logg+1)//2 - logg
    return n//f + summ
n, b = map(int, input().strip().split())
factor = fac(b)
s_f = set(factor)
co = {}
for i in s_f:
    co[i] = count(n,i)
cc = Counter(factor)
mm = int(1e200)
for a,c in cc.items():
    #print(a,c,co)
    if a in co:
        #print (co[a],a,c)
        mm = min(mm,co[a]//c)
    else:
        mm = 0

print(float_to_str(mm))


fact = [1]
def combi(a,i):
    return fact[a]/(fact[a-i]*fact[i])
def atLeastOne(a):
    ans = 0
    for i in xrange(1,a+1):
        temp = -1
        if i%2:
            temp = 1
        ans += temp*combi(a,i)*fact[a-i]
    return ans
n,k = map(int, raw_input('').strip().split(' '))
final = 0
for i in xrange(1,n+1):
    fact.append(fact[i-1]*i)
t = n - k - 1
for i in xrange(t+1):
    final += combi(n,i)*(fact[n-i] - atLeastOne(n-i))
print fact[n]-final


c=0
	while(a[c]>=10):
		a.append(int((0.90 *(a[c]))-k))
		c=c+1
	return 0.10 * sum(a)

def process():
    n=int(raw_input())
    l=0
    u=n
    a=list()
    while(l<=u):
        k=int((l+u)/2)
        a.append(n-k)
        petaya=int(sum_for_k(n,k,a))
        vatsaya=n-petaya
        if vatsaya<petaya:
            l=k+1
        else:
            u=k-1
    print(l)

process()


def maximum(l,r):

    current = 0
    for i in range(l,r+1)[::-1]:
        #print(i,"*")
        for j in range(l,i+1):
            #print(i, j)
            if i^j > current:
                current = i^j

    return current

inp = input()
l, r = inp.split(" ")
print(maximum(int(l),int(r)))


import math

def lcm(a, b):
    return int(a * b / math.gcd(a, b))

t = int(input())
for _ in range(t):
	n = int(input())
	ans = n-1
    for g in range(1,int(math.sqrt(n))+1):
        if (n % g == 0):
            ans = min(ans,n-g)
            if (g > 1): ans = min(ans, n-n/g)
	print(n-ans,ans)


n, m = map(int, input().split())
ans = (n * m) // 5
if (n * m) % 5 == 4 || (n * m) % 5 == 1:
    ans += 1
print(ans)
#try 2


n,m = map(int,input().split())
count=0
flag=0
if m%n!=0:
	print(-1)
else:
	if(m==n):
	    print(0)
		exit()
	m=m//n
	count+=1
	while(m!=1):
		if(m%2==0):
			m=m//2
			count+=1
		elif(m%3==0):
			m=m//3
			count+=1
		elif(m!=1):
			flag=1
			break;
	if(flag==1):
		print(-1)
	else:
		print(count-1)


a,b,c,d=map(int,input().split())
e=a+b+c+d
if(e%2==0):
    print("YES")
else:
    if((a+b)==(c+d) or (a+c)==(b+d)):
        print("YES)
    elif((a+c)==(b+d)):
        print("YES")
    elif(a+b+c==d or b+c+d==a):
        print("YES")
    elif(a+b+d==c or a+c+d==b)
        print("YES")
    else:
        print("NO")


a = int(input())
res = a * 6 + ( a - 1)
print res


w = int(input())
if(w%2==0):
    print(1):
else:
    print(2)


a,b = map(int,input().split())
days = list(map(int,input().split()))
c = max([days[i]-days[i+1] for i in range(len(days)-1)])-b)
print(c) if c > 0 else print(0)


import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

n, b = map(int, raw_input().split())
x = map(int, raw_input().split())
X = 0
for xi in x:
	X = X * b + xi
n, b = map(int, raw_input().split())
y = map(int, raw_input().split())
Y = 0
for yi in y:
	Y = Y * b + yi:
if X == Y:
	print "="
elif X > Y:
	print ">"
else:
	print "<"


    d = {
        'm': 10,
        's': 30,
        'p': 60
    }

    a, b, c = list(sorted([int(i[0]) + d[i[1]] for i in input().split(' ')]))

    if (a == b and b == c) or (a == b - 1 and b == c - 1):
        print(0)
        exit()
    if a == b - 1 or b == c - 1 or a == b or b == c or a == c - 2 or a == b - 2 or b == c - 2:
        print(1)
        exit()
    print(2)


is = input()
n = len(s)
for i in 'RBYG':
    pos = s.find(i) % 4
    print("%d " % (n // 4 + (n % 4 > pos) - s.count(i)), end="")


a = list(input())
b = int(input())
a.sort()
a = a[::-1]
prefix = ""
while(len(a) > 0):
	for i in range(len(a)):
		num = prefix+a[i]+"".join(sorted(a[:i]+a[i+1:]))
		if(int(num)<=b:
			prefix+=a[i]
			a=a[:i]+a[i+1:]
			break
print(prefix)


#include<iostream>

using namespace std;

int main()
{
    unsigned long long n,m;
    cin >> n >> m;
    while(true)
    {
        n++;
        if (n%m == 0)
        {
            cout << n;
            break;
        }
    }
    return 0;
}


x=int(input()
for i in range(x):
    print(int(input())//x)


x, t, a, b, da, db = map(int,raw_input().split(" "))
p=0
for x in range(0,t):
    a-=da*x
    for y in range(0,t):
        b-=db*y
        if a+b==x:
            p=1
            break
if p==1:
    print "YES"
else:
    print "NO"


num=""
input(num)
if num>9223372036854775807:
    print("BigInteger")
elif num>2147483647:
    print("long")
elif num>32767:
    print("int")
elif:
    print("short")
else:
    print("byte")


l = int(input())
if(l%2==0):
	print l/2
else:
	print -(l+1)/2


def binarypower(a,b):
    ans=1
    while(b>0):
        if b%2:
            ans=(ans*a)%1000000007
        a=(a*a)%1000000007
        b>>1
    return ans

for i in range(int(input()):
    n,k=map(int,input().split())
    print(binarypower(n,k))


// D.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <deque>
#include <unordered_set>

int main()
{
    int n, x;
    std::cin >> n >> x;

    unsigned long long oklow = 1, okmax;
    for (int i = 0; i < n - 1; ++i)
    {
        oklow *= 10;
    }

    okmax = oklow * 10 - 1;

    if (x == 1)
    {
        std::cout << "-1\n";
    }
    else
    {
        std::deque<std::pair<unsigned long long, int>> Q;
        Q.push_back(std::make_pair(x, 0));

        std::unordered_set<unsigned long long> V;

        auto e = std::make_pair<unsigned long long, int>((unsigned long long)x, 0);
        while (!Q.empty())
        {
            e = Q.front();
            Q.pop_front();

            if (oklow <= e.first && e.first <= okmax)
                break;

            V.insert(e.first);

            int mask = 0;
            auto v = e.first;
            while (v != 0)
            {
                auto m = v % 10;
                if ((m > 1) && ((mask & (1 << m)) == 0))
                {
                    if (V.find(e.first * m) == V.end())
                    {
                        Q.push_back({ e.first * m, e.second + 1 });
                    }
                }

                mask |= (1 << m);
                v /= 10;
            }
        }

        if (oklow <= e.first && e.first <= okmax)
            std::cout << e.second << "\n";
        else
            std::cout << "-1\n";
    }
}


import numpy as np

#arr = input()
#l = list(map(int,arr.split(' ')))

str_arr = raw_input().split(' ')
arr = [int(num) for num in str_arr]

n=arr[0]
k=arr[1]

#arr = input()
#l = list(map(int,arr.split(' ')))

str_arr = raw_input().split(' ')
arr = [int(num) for num in str_arr]
np_l = np.array(arr)

total = sum(np_l)
cnt = 0
for i in range(k):
        sub = abs(total-sum(np_l[i::k]))
        cnt = max(sub,cnt)
        #print(i,sub,cnt)

print(cnt)


a, b, c = map(int, input().split(' '))
l = 0
r = 1000000
res = 0
while l < r - 1:
	res = (l + r) // 2
	if res * b + b * c >= a * c:
		r = res
	else:
		l = res
res = l
while res * b + b * c < a * c:
	res += 1

print(res)


#include<bits/stdc++.h>

#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(c) int((c).size())
using namespace std;

vector<char> c={'R','O','Y','G','B','I','V'};
vector<int> s={0,0,0,1,1,1,1};
vector<vector<int> > cmb;

int main(){
  int n; scanf("%d", &n);
  int k=n/4+1;
  int cnt=0;
  do{
    cmb.pb(s);
    cnt++;
  }while(next_permutation(all(s)) && cnt<k);
  cnt=0;
  for(auto e:cmb)
    for(int i=0;cnt<n && i<7;i++)
      if(e[i]==1)
        printf("%c",c[i]), cnt++;
  printf("\n");
}


from collections import Counter

def gcd(x, y):
    """greatest common divisor of x and y"""
    while y:
        x, y = y, x % y
    return x

def memodict(f):
    """memoization decorator for a function taking a single argument"""
    class memodict(dict):
        def __missing__(self, key):
            ret = self[key] = f(key)
            return ret

    return memodict().__getitem__

def pollard_rho(n):
    """returns a random factor of n"""
    if n & 1 == 0:
        return 2
    if n % 3 == 0:
        return 3

    s = ((n - 1) & (1 - n)).bit_length() - 1
    d = n >> s
    for a in [2, 325, 9375, 28178, 450775]:
        p = pow(a, d, n)
        if p == 1 or p == n - 1 or a % n == 0:
            continue
        for _ in range(s):
            prev = p
            p = (p * p) % n
            if p == 1:
                return gcd(prev - 1, n)
            if p == n - 1:
                break
        else:
            for i in range(2, n):
                x, y = i, (i * i + 1) % n
                f = gcd(abs(x - y), n)
                while f == 1:
                    x, y = (x * x + 1) % n, (y * y + 1) % n
                    y = (y * y + 1) % n
                    f = gcd(abs(x - y), n)
                if f != n:
                    return f
    return n

@memodict
def prime_factors(n):
    """returns a Counter of the prime factorization of n"""
    if n <= 1:
        return Counter()
    f = pollard_rho(n)
    return Counter([n]) if f == n else prime_factors(f) + prime_factors(n // f)

def distinct_factors(n):
    """returns a list of all distinct factors of n"""
    factors = [1]
    for p, exp in prime_factors(n).items():
        factors += [p**i * factor for factor in factors for i in range(1, exp + 1)]
    return factors

def all_factors(n):
    """returns a sorted list of all distinct factors of n"""
    small, large = [], []
    for i in range(1, int(n**0.5) + 1, 2 if n & 1 else 1):
        if not n % i:
            small.append(i)
            large.append(n // i)
    if small[-1] == large[-1]:
        large.pop()
    large.reverse()
    small.extend(large)
    return small

def process(n, m):
    answer = 1
    checking = [0 for i in range(20)]
    L = [0 for i in range(19*m+20)]
    for g in range(1, 20):
        S = 0
        for i in range(1, m+1):
            if L[g*i]==0:
                S+=1
                L[g*i] = 1
        checking[g] = S
    for i in range(2, n+1):
        f = prime_factors(i)
        g = None
        for p in f:
            k = f[p]
            if g is None:
                g = k
            else:
                g = gcd(g, k)
        if g is None:
            g = 1
        answer+=(checking[g])
    return answer, checking

n, m = [int(x) for x in input().split()]
print(process(n, m))


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
string code;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    #endif // OnLINE_JUDGE
    cin >> code;
    string x;
    map<string, char> dic;
    for (int i=0 ; i<10 ; i++)
    {
        cin >> x;
        for (int j=0; j<=10 ; j++)
            dic[x] = (char)(i + '0');
    }
    string ans = "";
    for (int i=0 ; i<=8 ; i++)
    {
        string c = code.substr(i*10, 10);
        ans += dic[c];
    }
    cout << ans << endl;

    return 0;
}


f = open('input.txt', 'r')
f1=f.read()
x,y,z,t1,t2,t3 = map(int,f1.split())
f.close()
print(x)
s='NO'
if abs(z-x)*t2+abs(y-x)*t2+3*t3<=abs(y-x)*t1 :
   s='YES'
g = open('output.txt', 'w')
g.write(str(s))
g.close()


first = input()
second = input()
i = 1
s = ""
while first[i]>second[0] :
    s += first[i]
    i++
print(s+second[0])


def scm(x1, y1, x2, y2, x3, y3):
  return (x2 - x1) * (x3 - x1) + (y2 - y1) * (y3 - y1)
def scma(a):
  return (a[1] - a[0]) * (a[2] - a[0]) + (a[4] - a[3]) * (a[5] - a[3])
pair = [1, -2, 1]
f = False
p = [int(i) for i in input().split()]
if scma(p) == 0:
  print('RIGHT')
else:
  for i n range(6):
    for j in pair:
      p[i] += j
      if scma(p) == 0:
      f = True
if f:
  print('ALMOST')
else:
  print('NEITHER')


n=int(input())
x=list(map(int,input().split()))
a=x[0]
f=[]*n
for i in range(len(x)):
    f[x[i]-1}]=x[i]
for i in f:
    if a<f[i]:
        a=f[i]
for i in range(len(f)):
      if a%f[i]==0:
          x[f[i]-1]=0
b=1
for i in x:
    if b<x[i]:
        b=x[i]
print(a,b)


#include <iostream>
#include <cstdio>
#include <vector>
#include <string>

using namespace std;

int main()
{
    int n,j;
    string s,mop;
    cin >> n >> s;
    mop=s;
    for(int i=0;i<n-2;i++)
    {

        cout<< mop.substr(i,3) << endl;
        if(mop.substr(i,3)=="ogo")
        {

            j=i;

            if (j!=n-3){
            while(mop.substr(j+3,2)=="go" && j<n) j+=2;}
            j+=3;
            if(j==n)
            {mop=mop.substr(0,i)+"***";
            break;
            }
            else mop=mop.substr(0,i)+"***"+mop.substr(j);
        }
    }
    cout << mop;
    return 0;
}


n, k=int(input().split(' '))

if(k!=n):
	print(3*n+k-1)
else:
	print(3*n)


from operator import itemgetter
#int(input())
#map(int,input().split())
#[list(map(int,input().split())) for i in range(q)]
#print("YES" * ans + "NO" * (1-ans))
s = input()
alth = "auoie"
ans = "YES"
for i in range(len(s) - 1):
    if alth.find(s[i]) == -1 and  s[i] != "n":
        if alth.find(s[i+1]) == -1:
            ans = "NO"
if alth.find(s[-1]) == -1 and  s[i] != "n"::
    ans = "NO"
print(ans)


n,t=map(int.input().input()
k=-1
for i in range (10**(n-1),10**n):
    t%i==0
    k=i
    break
print(k)


a, b = map(int,raw_input().split())

total_burned = a
current_candles= a

while True:

    if current_candles < b:
        break

    new_candles= current_candles/b
    left = current_candles%b
    total_burned += new_candles
    current_candles =new_candles + left

 print total_burned


upvotes, downvotes, uncertain = map(int, input().split())

if upvotes > (downvotes+ uncertain):
    return "+"
elif downvotes >(upvotes+ uncertain):
    return "-"
elif (uncertain == 0) and (upvotes == downvotes):
    return "0"
else:
    return "?"


import sys
while(True):
n = int(sys.stdin.readline())
gx, gy = tuple(map(int,sys.stdin.readline().split()))

wi, wj, bi, bj = 1, 1, n, n

while(True):
    if (wi, wj) == (gx, gy):
        print("White")
        break
    if (bi, bj) == (gx, gy):
        print("Black")
        break

    if wi < gx:
        wi+=1

    if wj < gy:
        wj+=1
#     print(wi, wj)
    if (wi, wj) == (gx, gy):
        print("White")
        break

    if bi > gx:
        bi-=1

    if bj > gy:
        bj-=1
#     print(bi, bj)
    if (bi, bj) == (gx, gy):
        print("Black")
        break


F=input()
M=input()
S=input()

Beater = {"paper":"rock","rock":"scissors","scissors","rock"}

if(M==S and F==Beater[M]):
    print("F")
elif(F==S and M==Beater[F]):
    print("M")
elif(F==M and S==Beater[F]):
    print("S")
else:
    print("?")


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

steps = dict()
for x in range(n):
    steps[x] = (x+1,1)

current = n*m - 1
if k < n:
    print (k+1,1)
else:
    remaining = k - n
    row_from_down = remaining // 2

    row = n - row_from_down
    # 11 10
    if row%2:
        col = remaining % (m-1)
        col = m - col

    else:
        col = remaining % (m-1)
        col += 2
    print (row, col)


n = input().split()
a = int(n[0])
b = int(n[1])

m = input().split()
c = int(m[0])
d = int(m[1])

for i in range(100):
    for j in range(100):
        if(a*i+b=c*j+d):
            print (b+a*i)

print ("-1")


#include <iostream>
#include <vector>

int main(){

    const int64_t D = (2 * 2 * 2) * (3 * 3) * 5 * 7;
    int64_t n; std::cin >> n;
    std::cout << (n / D) << std::endl;

    return 0;
}
// 1537623927916


n, z1, k1 = map(int, input().split())

z1 -= 1

k1 -= 1

s = input()

if (s == 'to head'):

    napr = -1

else:

    napr = 1

s = input()

for i in range(len(s)):

    if (k1 == z1):

        print('Controller', i)

        exit(0)

    if (s[i] == '0'):

        if (k1 > z1 and z1 != 0):

            z1 -= 1

        elif (k1 < z1 and z1 != n - 1):

            z1 += 1

        k1 += napr

        if (k1 == 0 or k1 == n - 1):

            napr = -napr

    else:

        k1 += napr

        if (k1 == 0 or k1 == n - 1):

            napr = -napr

        if (k1 == 0):

            z1 = n - 1

        elif (k1 == n - 1):

            z1 = 0

        elif (napr == 1 and k1 != 0):

            z1 = 0

        else:

            z1 = n - 1

    #print(z1 + 1, k1 + 1)

    if (k1 == z1):

        print('Controller', i + 1)

        exit(0)

print('Stowaway')

# Made By Mostafa_Khaled


t=int(input())
for _ in range(t):
    k=int(input())
    w=100-k
    for i in range(1,min(w,k)):
        if w%i==0 and k%i==0:
            w%=i
	    k%=i
    print(w+k)


a,b=map(int,input().split())
l=list(map(int,input().split()))
if sum(l)+10*(a-1)>b:
    print("-1")
else:
    print(b-sum(l))//5)


n = int(input())
a = list([int(s) for s in input().split()])
m = []
for i in range(1,n):
        for j in range(i,n+1):
                print(i,j)
            b = a[:]
            a_new = b[i:j]
            for index,s in enumerate(a_new):
                if s == 1:
                    a_new[index] = 0
                elif s == 0:
                    a_new[index] = 1
                b[i:j] = a_new
                m.append(b)
otvet = max(s.count(1) for s in m)
print(otvet)


t=int(input())
def pp(n,k,d,seasons):
    ress=k+1
    for i in range (n-d+1):
        pay=[]
        for l in seasons[i: i+d]:
            if l not in pay:
                pay.append(l)
        ress =min(ress,len(pay))
    print(ress)
for j in range(t):
    n,k,d=map(int,input().split())
    seasons=input().split()
    pp(n,


from math import log

w,m,k = map(int,input().split())
d = 0
while w > 0:
	z = int(log(m,10)) + 1
	zlom = 10**z
	c = (zlom-m)*z*k
	if (c > w):
		x = w//(z*k)
		d+=x
		break
	w-=c
	d+=(zlom-m)
	m = zlom
print(d)


n=int(input())
a=input()
a=list(map(int,a.split(" ")))
x=[]
m=-1
if n==1:print(0)
else:
    for i in range (0,n-1):
        if a[i]==a[i+1]-1:
            m+=1
        else :
            x.append(m)
            m=-1
    if m>-1:
        x.append(m)

    if a[0]==1:
        x[0]=x[0]+1
    if a[n-1]==1000:
        x[-1]+=1
    m=x[0]

    for i in range(1,len(x)):
        if m<x[i]:
            m=x[i]
    if m=-1:
        print(0)
    else:print(m)


def fazTudo():
	ar,br,cr = map(int,input().split());
	aw,bw,cw = map(int,input().split());
	res = 1;
	if ar==0 and br==0 and cr==0 and aw==0 and bw==0 and cw==0:
		print("-1");
		return;
	if ar==0 and br==0 and cr!=0 or aw==0 and bw==0 and cw!=0:
		print("0");
		return;
	a1 = -(ar/br);
	b1 = -(cr/br);
	a2 = -(aw/bw);
	b2 = -(cw/bw);
	if(a1==a2):
		if(b1==b2):
			res = -1;
		else:
			res = 0;

	print(res);
fazTudo();


from itertools import groupby
print(sum(1 for k, g in groupby(input()) if len(list(g)) % 2 == 0))


n = long int(input())
n = n + 1
if n % 2 == 1:
	print(n)
else:
	print(long int(n/2))


t = int(input())
N = []
for i in range(t):
	N.append((input())

for i in N:
	x = len(i)
	y = int(N[0])
	s = 0
	s = (x(x+1)/2) +  10*(y-1)
	print(s)


n=int(input())
l=[]
for i in range(n):
    l1=list(map(int,input().split()))
    l.append(l1)
c=0
for i in range(n):
    for j in range(n):
        if l[i]==l[j]
        c+=1
print(c)


n,k=map(int,input().split())
time=240-k
count=0
ans=0
for i in range(1,n):
    ans+=5*i
    if(ans>time):
    break
count+=1


s = input()
i = 1
d = {}
d[s] = 1
while (i<=len(s) + 1):
    s = s[len(s) - 1] + s[:-1]
    #print(s)yz
    d[s] = 1
    i+=1

print(len(d))aaa


n=int(input())
if(n%2==0):
	a,b=n//2,n//2
else:
	a,b=n//2,n//2+1
for i in range(10):
	if(a==1):
		print(a,b)
		break
	l=[i  for i in range(1,a+1) sif a%i==0]
	s=[i  for i in range(1,b+1) if b%i==0]

	if(len(set(l+s))==len(l)+len(s)-1):
		print(a,b)
		break
	else:
		a,b=a-1,b+1


n=int(input())
s=input()
num=0
color=s[0]
for i in range(1,n):
    if s[i]=color:
        num+=1
    else:
        color=stone[i]
print(num)


n = int(input())
pos = 0
flag = True
for x in range(n):
  t, d = input().split()
  t = int(t)
  if t < 0 or t > 20000:
    flag = False
    break
  elif if d[0] == "N":
    pos -= t
  elif d[0] == "S":
    pos += t
  elif pos == 0 and d[0] != "S":
    flag = False
    break
  elif pos == 20000 and d[0] != "N":
    flag = False
    break
if pos == 0 and flag == True:
  print("YES")
else:
  print("NO")


def MinDistance(x1, x2, x3):
	d1 = x1 + x2
	d2 = 2*d1
	if d2 > d1 + x3:
		return d1 + x3
	return d2

print MinDistance(x1, x2, x3)


from fractions import Fraction
n = list(map(int,input().split()))
n.sort()
s=0
for i in range(n[1],7,1):

print(Fraction(s,6))


import math
ck="abcdefghijklmnopqrstuvwxyz"
n=input()
if abs(ck.index(n[0]) < 26-abs(ck.index(n[0]):
    s=abs(ck.index(n[0])
else:
    s=26-abs(ck.index(n[0])
for i in range(1,len(n)):
    if abs(ck.index(n[i])-ck.index(n[i-1])) < 26-abs(ck.index(n[i])-ck.index(n[i-1])):
        s+=abs(ck.index(n[i])-ck.index(n[i-1]))
    else:
        s+=26-abs(ck.index(n[i])-ck.index(n[i-1]))
print(s)


a,b = map(int,input().split())
ans = 1
if(a == 0):
	if(b>=10):
		print(0)
	else:
		while(b > 0):
		b -= 1
		ans *= ((b+1)%10)
		ans %= 10
		print(ans)

elif(b == 0):
	print(1)
else:
	if(b-a>=10):
		print(0)
	else :
		while(b != a):
			ans *= b%10
			ans %= 10
			b -= 1
	     	print(ans)


n = int(input())
if n%2===0:
    print('white')
    print(1,2)
else:
    print("black")


n=(input())
f=list(map(int,(n[:3])))
l=list(map(int,(n[3:])))

s=0
sf=sum(f)
sl=sum(l)
if sl> sf:
    d=sl-sf
    f.sort()
    if (f[0]+d)>=10:
        if f[1]-9+d>=10:
            s=3
        else:
            s=2
    else:
        s=1

elif sf> sl:
    d=sf-sl
    l.sort()
    if l[0]+d>=10:
        if l[1]-9+d>=10:
            s=3
            else:
            s=2
    else:
        s=1

print(s)


n, k =list(map(int(,input().split())))
for i in range(k):
	if n%10==0:
		n//=10
	else:
		n-=1
print(n)


import sys
the_list = sys.stdin.readlines()
the_list[1].rstrip()
//slist = [int(x) for x in the_list[1].split()]
//slist.sort()
//for x in slist:
    //print(x + ' ')
print("yeppers")


M = 10**9+7
x, k = map(int, raw_input().split())
x %= M
if k == 0:
	print (2*x)%M
if x == 0:
	print 0
else:
	print (4*x-2)%M*pow(2, k-1, M)+1%M


input_arr = raw_input()
items = "abcdefghijklmnopqrstuvwxyz"
ans = []
for i in input_arr();
    if len(items) > 0 and items[0] < i:
      ans.append(i)
    else:
      ans.append(items[0])
      items = items[1:]
if len(items) == 0:
  print ''.join(ans)
else:
  print -1


l=list(map(int,input().split()))
c=list(filter(lambda x:l.count(x)>1,l))
c=list(set(c))
f=[]
if c!=[]:
     d=max(c)
     if l.count(d)>2:
          f=f+[sum(l)-3*d)]
     elif l.count(d)==2:
          f=f+[sum(l)-2*d)]
     r=[l.count(i) for i in c]
     e=d.index(max(r))
     if max(r)>2:
          f=f+[sum(l)-3*c[e])]
     elif max(r)==2:
          f=f+[sum(l)-2*c[e])]
else:
     print(sum(l))


from string import*
n = int(input())
#n,m = map(int,input().split())
a = list(map(int,input().split()))
s = list(ascii_lowercase)[:n]
res = []
'''x = set()
for i in range(n):
    if a[i] in x:
        f = a[i]+1
        res.append(f*s[i])
        x.add(f)
    else:
        res.append(a[i]*s[i])
        x.add(a[i])
print(len(''.join(map(str,res))))'''

a.sort(reverse=True)
for i in range(n):
    if a.count(a[i])>1:
        a[i]-=(a.count(a[i])-1)

for i in range(n):
    res.append(a[i]*s[i])
print(len(''.join(map(str,res))))


n, m = list(map(int, "input().split(" ")))

def count_friends(num):
    return int(((num-1)/2)*(num))

#Max
maxFriends = count_friends(n - (m-1))

#Min
minFriends = 0
if n % m == 0:
    min = int(n/m)
    minFriends += count_friends(min)*m
else:
    roundNum = int(n/m)
    ostatok = n % m
    minFriends += count_friends(roundNum) * (m - ostatok)
    minFriends += count_friends(roundNum + 1) * ostatok

print(str(maxFriends) + " "  + str(minFriends))


import math
a, b, c, d = map(int, input().split())

if c/d == a/b:
    print(0, '/', 1, sep = '')
elif c/d < a/b:
    print((d*a -b*c)//math.gcd(d*a -b*c, d*a), '/', d*a//math.gcd(d*a -b*c, d*a), sep = '')
else:
    print(b*c - d*a//math.gcd(b*c - d*a, b*c), '/', b*c//math.gcd(b*c - d*a, b*c, sep = '')


def gcd(a, b):
    if a == 0 : return b
    if b == 0: return a
    return gcd(b, a % b)

N, K = map(int, input().split())
A, B = map(int, input().split())
S = [A, K - A]
E = []
for i in range(N):
    if i * K + B >= 0:
        E += [i * K + B]
    if i * K - B >= 0:
        E += [i * K - B]
l = set()

for e in E:
    l.add(abs(e - S[0]))
    l.add(abs(e - S[1]))

mi, ma = None, None

f = N * K
#print(l)
for i in l:
    rounds = f // gcd(i, f)
    if mi == None:
        mi = rounds
        ma = rounds
    else:
        mi = min(mi, rounds)
        ma = max(ma, rounds)
print(mi, end=' ')
print(ma)

'''
2 3
1 1
outputCopy
1 6
inputCopy
3 2
0 0
outputCopy
1 3
inputCopy
1 10
5 3
outputCopy
5 5
'''


a=int(input())
b=int(input())
elif b/a<1:
    print(b)
else:
    print(b%2**a)


a, b = input().split()
print(int(a) + int(reversed(b)))


pingnian = [31,28,31,30,31,30,31,31,30,31,30,31]
runnian = [31,29,31,30,31,30,31,31,30,31,30,31]
sequence = pingnian + pingnian + runnian + runnian + pingnian

n = input()
months = list(map(int,input().split()))
left = 0, right = n
exist = 0
while right <= len(sequence):
	sub = sequence[left:right]
	if sub == months:
		exist = 1
		break
	left += 1
	right += 1
if exist:
	print(Yes)
else:
	print(No)


s = inpur()
if "ABC" in s or "ACB" in s or "BAC" in s or "BCA" in s or "CAB" in s or "CBA" in s:
    print("YES")
    else:
        print("NO")


def c(n,k)
    r = 1
    for j in range(1,k+1):
        r = r * (n - k + j)
    for j in range(1,k+1):
        r = r / j
    return r

n,m,k = map(int,raw_input().split())
a = 0
for i in range(1,k+1):
    if (i <= m && k - i <= n && k - i >= 4):
        ans += c(k - i, n) * c(i, m)
print ans


s = raw_input() + raw_input() + raw_input()
for i in range(5):
    if s[i] ! = s[8 - i]:
        print 'NO'
        exit( )
print 'YES'


    r1,r2 = map(int,input().split())
    c1,c2 = map(int,input().split())
    d1,d2 = map(int,input().split())
    y = (d2+(r2-c2))//2
    x = d2-y
    w = r1-x
    z = d1-w
    if not 1<w<20 or not 1<x<20 not 1<y<20 or 1<z<20:
        print(-1)
        exit()
    if w != x and w != y and w != z and x != y and x != z and y != z:
        print(-1)
        exit()
    else:
        print(w,x)
        print(y,z)


n = int(input())
arr = [int(i) for i in input().split()]

count = [0, 0]
for i in arr:
    count[i//100 - 1] += 1
print(count)
#print(count[0] + count[1]*2)
if not count[0]% 2 and (count[1]%2==0 or ((count[0]//2)%2 == 0):
    print('YES')
else:
    print('NO')


MOD = 998244353
def inv(x):
    return pow(x, MOD - 2, MOD)

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

mult = n * inv(m + 1) + 1
mult %= MOD

currN = 1
out = m + 1
while currN < n:
    currN += 1

    out += m * inv(currN)
    out %= MOD

out *= mult
print(out % MOD)


n = int(input())
if(n % 2 == 0)
    print(2)
else:
    print(1)


from sys import stdout
from sys import stdin
def get():
    return stdin.readline().strip()
def getf():
    return [int(i) for i in get().split()]
def put(a, end = "\n"):
    stdout.write(str(a) + end)
def putf(a, sep = " ", end = "\n"):
    stdout.write(sep.join(map(str, a)) + end)

def matrix(n, m, a = 0):
    return [[a for i in range(m)]for j in range(n)]

def transf(a, k):
    s = ""
    while(a >= k):
        s += str(a % k)
        a //= k
    s += str(a)
    return s[::-1]

def main():
    n = int(get())
    t = matrix(n - 1, n - 1)
    for i in range(1, n):
        for j in range(1, n):
            t[i - 1][j - 1] = transf(i*j, n)
    for i in t:
        putf(i)
main()


import sys
a=sys.stdin.readline().rstrip().split()
b=sys.stdin.readline().rstrip().split()
# a=[10,19]
# b=[1,2]
cater=int(a[0])
apple=int(a[1])
night=int(b[1])
day=int(b[0])
days=0
found=False
while not found:
    start=cater-apple
    for i in range(0,8):
        cater=cater+day
        if cater==apple:
            found=True
            break
    for i in range(0,12):
        cater=cater-night
        if cater==apple:
            found= True
            break
    for i in range(0,4):
        cater=cater+day
        if cater==apple:
            found= True
            break
    end=cater-apple
    if found is True:
        print days
    days=days+1
    elif abs(end)>abs(start):
        print -1
        found=True


def p(x,n):
    ans=1
    if n==0:
        return ans
    for i in range(n):
        ans*=x-i
    return ans;

lest={'A','B','C','D','E','F','G','H','I','J'}
str=raw_input("")
k=0;l=0;ans1=0;
if str[0] in lest:
    is_it=True
for c in str:
    for L in lest:
        if L==c:
            l+=1
            lest.remove(L)
            break
for c in str:
    if c=='?':
        k+=1
if is_it:
        ans1=p(9,l-1)

ans=(10**k)*p(10,l)-ans1

if str[0]== "?":
    ans=ans*0.9
print ans


from sys import stdin

in_lines = ""
#if __debug__ :
#    in_lines = """
#6 7 4
#    """
in_lines = filter( lambda x: x, map( lambda l: l.strip(), in_lines.split('\n') ) )
else :
    in_lines = stdin.readlines()

def int_values(line) :
    return map( int, line.split(' ') )

lines = map( int_values, map( lambda x:x.strip(), in_lines  ) )

a, b, r = lines[0]
if ( 2 * r > min([a, b]) ) :
    print 'Second'
else :
    print 'First'


# -*- mode: python; encoding: utf-8; -*-

#print "------------------------------------"
#text = u"пушкин.рф"
#print text
#puny = encodings.punycode.punycode_encode(text)
#print puny
#print encodings.punycode.punycode_decode(puny, "")

s = "CPCPCPC"#raw_input()
n = len(s)
i = 0
ans = 0
while (i < n)
    cnt = 0;
    prev = s[i]
    while i < n and s[i] = prev and cnt < 5
        i += 1
        j += 1
    ans += 1
print ans


𝑛,𝑚,𝑟 = map(int,input().split())
s = [*map(int,input().split())]
p = [*map(int,input().split())]
mm=min(s)
yy=max(p)
qq=r//mm
print(max(qq*yy+(r%mm),r))


import math
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

t=int(input())
while t:
    n=int(input())
    xs=int(math.sqrt(n))
    count=0
    for i in range(1,xs+1):
        xs=n^i
        ys=n&i
        zs=gcd(xs,ys)
        count=max(zs,count)

    print(count)
    t-=1


n=int(input())
a=[1]*n
b=list(range(1,n+1))
while True:
    for i in range(1,n):
        a[i]=a[i-1]+b[i]
    if a[1]==n:
        print(a[n-1])
        exit(0)
    for j in range(1,n):
        b[j]=b[j-1]+a[j]
    if b[1]==n:
        print(b[n-1])
        exit(0)n=int(input())
x=1
a=[1]*n
b=list(range(1,n+1))
while True:
    for i in range(1,n):
        a[i]=a[i-1]+b[i]
    if a[1]==n:
        print(a[n-1])
        break
    for j in range(1,n):
        b[j]=b[j-1]+a[j]
    if b[1]==n:
        print(b[n-1])
        break


n, m, z = map(int, raw_input().split())
i = max(n, m)
j = min(n, m)
c = 1
kills = 0
while i <= z:
    if i % j == 0:
        kills += 1
    c += 1
    i *= c

return kills


s=input()
l=len(s)
if l>=5:
    A=0
    a=0
    d=0
    for i in s:
        if A>0 and a>0 and d>0:
            break
        if i>='a' and i<='z':
            a=a+1
        elif i>='A' and i<='Z':
            A+=1
        try:
            k=int(i)
            d=d+1
        else:
            pass
    if A>0 and a>0 and d>0:
        print('Correct')
    else:
        print('Too weak')
else:
    print('Too weak')