peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
from collections import Counter


n, k  = map(int, input().split())
m = Counter(input().split())
print(sum(sorted(m.values(), reverse=True)[k:]))
# Judge status: Wrong Answer
def main():
    N = int(input())
    A = list(map(int, input().split()))

    re = []

    for i in range(N):
        re.insert(A[i] - 1, i + 1)

    print(*re)


if __name__ == "__main__":
    main()
# Judge status: Accepted
import bisect

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

towers = []
last = 0
for i in range(1, 1000):
    towers.append(last+i)
    last += i

diff = b - a

print(towers[diff-1] - b)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
import collections

c = collections.Counter(A)
c = c.most_common()
if c[0][1] == 1:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
from itertools import permutations 

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

perm = list(permutations(range(1, N+1), N))
print(abs(perm.index(P) - perm.index(Q)))
# Judge status: Wrong Answer
s = int(input())
if(s >=1800 and s<2000):
  print(1)
elif(s>=500 and s<800):
  print(7)
elif(s>=800 and s<1000):
  print(6)
elif(s>=1000 and s<1200):
  print(5)
elif(s>=1200 and s<1400):
  print(4)
elif(s>=1400 and s<1600):
  print(3)
elif(s>=1600 and s<1800):
  print(2)
else:
  print(8)
# Judge status: Accepted
n, k  =  map(int,input().split())

if n == 1:
    print(1)
else:
    a=1
    ans = 0
    while a<=n:
        a *=k
        ans += 1

    print(ans)
# Judge status: Accepted
#! /usr/bin/env python3

from fractions import gcd
# from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

ans = lambda x : x % 998244353
MOD = 998244353

N = int(input())
D = [int(_) for _ in input().split()]

c = Counter(D)

ans = 1 * (not D[0]) * (c[0] == 1)
for i in range(1, max(c.keys())+1):
    ans *= pow(c[i-1], c[i], MOD)
    ans %= MOD

print(ans)
# Judge status: Accepted
d = int(input())
c = list(map(int,input().split()))
ans = []
for i in range(d):
    s = list(map(int,input().split()))
    ans += [s.index(max(s))+1]
for i in ans:
    print(1)
# Judge status: Accepted
A,B,C = map(int,input().split())

if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
    ans = 0
else:
    ans = min(A*B,B*C,C*A)
print(ans)
# Judge status: Wrong Answer
n = int(input())
s = set()

sub = 1
while n != 0:
    new = n - sub
    if new not in s:
        print(sub)
        s.add(sub)
        n = new
    sub += 1
# Judge status: Accepted
x, a, b = map(int, input().split())
if abs(a-x) < abs(b-x):
    print('A')
else:
    print('B')
# Judge status: Accepted
N, K = map(int, input().split())

if N<K:
    if N>K/2:
        print(K-N)
    else:
        print(N)

elif N==K:
    print(0)
else:
    amari = N%K
    if amari>K/2:
        print(K-amari)
    else:
        print(amari)
# Judge status: Accepted
n = int(input())
s = input()
s = list(s)
a = ''
for i in range(len(s)):
    if 'A' <= chr(ord(s[i]) + n) and chr(ord(s[i]) + n) <= 'Z':
        s[i] = chr(ord(s[i]) + n)
    else:
        s[i] = chr(ord('A') + (ord(s[i]) + n) % (ord('Z') + 1))
    a += s[i]
print(a)
# Judge status: Wrong Answer
N,K,X,Y=[int(input()) for i in range(4)]

if(K>N):
  N=K
else:
  N=N
Z=K*X+(N-K)*Y
print(Z)
# Judge status: Accepted
a,b=map(int,input().split())
arr=list(map(int,input().split()))
c=1
s=0
for i in range(a):
	s+=arr[i]
	if s<=b:
		c+=1
	else:
		break	
		
print(c)
# Judge status: Accepted
N = int(input())
a = [0]+list(map(int, input().split()))
b = [0 for _ in range(N+1)]

for i in reversed(range(1, N+1)):
    tmp = 0
    for j in range(i, N+1, i):
        tmp += b[j]
            
    if(tmp%2 == a[i]):
        b[i] = 0
    else:
        b[i] = 1


ans = []
for i, j in enumerate(b):
    if(j == 1):
        ans.append(i)
print(len(ans))
if(len(ans)):
    print(*ans)
# Judge status: Accepted
n = int(input())
d = dict()

for _ in range(n):
    s = input()

    if s in d:
        d[s] += 1
    else:
        d[s] = 1


items = list(d.items())
max_num = max([v[1] for v in items])
ans = []

for k,v in items:
    if max_num == v:
        ans.append(k)

ans.sort()

for v in ans:
    print(v)
# Judge status: Accepted
n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]

score = [0]*n
for i in a:
    score[i-1] += 1

for i in range(n):
    print("Yes") if k-q+score[i] > 0 else print("No")
# Judge status: Accepted
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)
    S = input()
    print(['ABC', 'ARC'][S == 'ABC'])


if __name__ == '__main__':
    main()
# Judge status: Accepted
#!/usr/bin/env python3
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
q = int(input())
cnt = Counter(a)
s = sum(a)
for _ in range(q):
    b, c = map(int, input().split())
    s += (c - b) * cnt[b]
    cnt[c] += cnt[b]
    cnt[b] = 0
    print(s)
# Judge status: Accepted
S = input()

s = S.replace('<>', '<,>').replace('><', '>,<').split(',')
lst = [ss.count('<') - ss.count('>') for ss in s]

ans = [0]

for i in lst:
    if i > 0:
        ans += list(range(1,i+1))
    else:
        ans[-1] = max(ans[-1], -i)
        ans += list(range(-i-1,-1, -1))

print(sum(ans))
# Judge status: Accepted
n = int(input())
k = int(input())
x = int(input())
y = int(input())

sum = 0
for i in range(0,n):
    if i<k:
        sum += x
    else:
        sum += y
print(sum)
# Judge status: Wrong Answer
N = input()

ans = 0

carry = 0

N_rev = N[::-1]

for i in range(len(N_rev)):
    if int(N_rev[i]) + carry <= 5:
        ans += (int(N_rev[i]) + carry)
        carry = 0
    else:
        ans += (10-int(N_rev[i])-carry)
        carry = 1


print(ans)
# Judge status: Accepted
lst = []
for i in range(int(input())):
    S,P = input().split()
    lst.append([S,int(P),i])

sorted_point = sorted(lst,key = lambda x: x[1], reverse = True)
sorted_name = sorted(sorted_point,key = lambda x: x[0], reverse = False) 

for i in sorted_name:
    print(i[2] + 1)
# Judge status: Wrong Answer
numero = int(input())
soma = 0
minimo = 100000
for aux in range(numero - 1,2,-1):
    prim = str(aux)
    seg = str(numero - aux)
    for x in range(len(prim)):
        soma += int(prim[x])
    for x in range(len(seg)):
        soma += int(seg[x])
    if soma < minimo :
        minimo = soma
    soma = 0
print(minimo)
# Judge status: Wrong Answer
import sys
N , K = map(int,input().split())
D = list(map(int,input().split()))
L = [i for i in range(10)]
for i in D:
  L.remove(i)
c = []
for i1 in L:
  for i2 in L:
    for i3 in L:
      for i4 in L:
        k = i1*1000 + i2*100 + i3*10 + i4
        c.append(k)
c.sort()
for i in range(len(c)):
  if c[i] >= N:
    print(c[i])
    sys.exit()
# Judge status: Accepted
N = int(input())

x = 800 * N
y = 200 * (N // 15)

total_Money = x - y
print(total_Money)
# Judge status: Wrong Answer
k=int(input())
if k % 2 == 0:
  print(k / 2 * k / 2)
else:
  print(k // 2 * (k // 2 + 1))
# Judge status: Accepted
N = int(input())

P = [1]

for i in range(1, N):
    if 6**i > N:
        break
    P.append(6**i)

for i in range(1, N):
    if 9**i > N:
        break
    P.append(9**i)

P.sort()

DP = [float('inf')] * (N + 1)
DP[0] = 0
for i in range(N):
    for p in P:
        if i + p > N:
            break
        DP[i+p] = min(DP[i+p], DP[i] + 1)
print(DP[N])
# Judge status: Accepted
from collections import defaultdict

s = input()
t = input()

dicts = defaultdict(int)
dictt = defaultdict(int)

cs = []
ct = []

for i in range(len(s)):
    dicts[s[i]] += 1
    dictt[t[i]] += 1
    cs.append(dicts[s[i]])
    ct.append(dictt[t[i]])


if cs == ct:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
def main():
    sx, sy, tx, ty = map(int, input().split())
    vert = ty - sy
    hor = tx - sx
    ans = 'U'*vert + 'R'*hor + 'D'*vert + 'L'*hor
    ans += 'L' + 'U'*(vert+1) + 'R'*(hor+1) + 'D'
    ans += 'R' + 'D'*(vert+1) + 'L'*(hor+1) + 'U'
    print(ans)
main()
# Judge status: Accepted
n = int(input())
al = [0] * n
bl = [0] * n
for i in range(n):
    al[i], bl[i] = map(int, input().split())

al.sort()
bl.sort(reverse=True)

if n % 2 == 0:
    print((bl[n//2-1] - al[n//2-1])+((bl[n//2] - al[n//2])+1))
else:
    print(bl[n//2] - al[n//2]+1)
# Judge status: Wrong Answer
n = int(input())

if n ==30:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
#!/usr/bin/env python3
S = input().strip()
T = input().strip()

trans = dict()
ans = True
for s, t in zip(S, T):
    if trans.get(s, t) != t:
        ans = False
        break
    trans[s] = t

# print(trans)
print('Yes' if ans and len(set(trans.values())) == len(trans) else 'No')
# Judge status: Accepted
K, X = map(int, input().split())

if(K * 500 >= X):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n, a, b, c, d = map(int, input().split())
s = list(input())

cant = False
if c>d:
        cant = True
        for i in range(max(0,b-2), min(d-1, n-2)):
                if s[i]==s[i+1]==s[i+2]=='.': cant = False

for i in range(b-1, d-1):
        if s[i]==s[i+1]=='#': cant = True
for i in range(a-1, c-1):
        if s[i]==s[i+1]=='#': cant = True

print("YNeos"[cant::2])
# Judge status: Accepted
from functools import reduce

def cmb(n,r,p):
    r = min(n-r,r)
    if r == 0:
        return 1
    num = reduce(lambda x, y: (x*y)%p, range(n,n-r,-1))
    den = reduce(lambda x, y: (x*y)%p, range(1,r+1))
    return (num * pow(den,p-2,p)) % p

m = 10**9 + 7
n,a,b = map(int, input().split())
ans = pow(2,n,m) - 1
ans -= cmb(n,a,m) + cmb(n,b,m)
print(ans % m)
# Judge status: Accepted
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N=readline().decode('utf8')
S=N[:3]+'8'+N[4:]
print(S)
# Judge status: Accepted
A, B, C = map(int, input().split())
print(C if C * A <= B else B // A)
# Judge status: Wrong Answer
import sys
n, k = list(map(int, input().split()))

if (k == 1):
    print(0)
    sys.exit()

s, a = divmod(n, k)

ans = 0
if (a == 0):
    ans = s
else:
    ans = a

print(ans)
# Judge status: Accepted
from sys import exit
n=int(input())
for i in range(1,10):
	for j in range(1,10):
		if i*j==n:
			print("Yes")
			exit()
print("No")
# Judge status: Wrong Answer
a, b = map(int, input().split())
if a >= 13:
    print(b)
elif a >=6 and a < 13:
    print(b/2)
else:
    print("0")
# Judge status: Accepted
n = int(input())
x0 = int(n/1.08)
if int(x0*1.08) == n:
    print(x0)
elif int((x0+1)*1.08) == n:
    print(x0+1)
else:
    print(':(')
# Judge status: Wrong Answer
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(x, y):
    return x / gcd(x, y) * y
n=int(input())
a=list(map(int,input().split()))
mod = 10**9+7
lc=1
for i in range(n):
    lc = lcm(lc,a[i])
print(lc)
print(a)
a = list(map(lambda x : (lc/x)%mod,a))
print(a)
print(sum(a)%mod)
# Judge status: Accepted
from collections import deque

N, M = map(int, input().split())
G = [[] for _ in range(N)]

for _ in range(M):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  G[a].append(b)
  G[b].append(a)

q = deque([0])
dist = [-1]*N
dist[0] = 0

while q:
  v = q.popleft()
  for nv in G[v]:
    if dist[nv] == -1:
      dist[nv] = v+1
      q.append(nv)

print("Yes")
print(*dist[1:], sep="\n")
# Judge status: Accepted
a, b, x = map(int, input().split())
print(b // x - (a + x - 1) // x + 1)
# Judge status: Wrong Answer
N, X, Y = map(int, input().split())

lists = [0] * (N - 1)

for i in range(N - 1):
  for j in range(i + 1, N):
    min_length = min(abs(j-i),abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(j-X))
    lists[min_length - 1] += 1

for k in lists:
  print(k)
# Judge status: Wrong Answer
import math
H, W = map(int, input().split())
print(math.ceil(H * W  / 2))
# Judge status: Wrong Answer
n = int(input())
l = []
for _ in range(2):
    a = list(map(int,input().split()))
    l.append(a)

if n == 1:
    print(l[0][0]+l[1][0])
    exit()

m1 = []
m2 = []
m1.append(l[0][0])
m2.append(l[1][0])

for i in range(1,n):
    m1.append(m1[i-1]+l[0][i])
    m2.append(m2[i-1]+l[1][i])

ans = [0]*n
for j in range(n):
    ans[j] = m1[j]+(m2[n-1]-m2[j-1])

print(max(ans))
# Judge status: Accepted
n = int(input())
A = [0]*n
B = [0]*n
for i in range(n):
    a,b = map(int, input().split())
    A[i] = a
    B[i] = b
A.sort()
B.sort(reverse=True)
if n%2 == 1:
    ans = B[(n+1)//2-1]-A[(n+1)//2-1]+1
    print(ans)
else:
    y = A[n//2-1] + A[n//2]
    x = B[n//2-1] + B[n//2]
    ans = x-y+1
    print(ans)
# Judge status: Accepted
time,rate = map(int,input().split())
ans = 0
if time >= 10:
  ans = rate
else:
  ans = rate + 100*(10 - time)
print(ans)
# Judge status: Wrong Answer
import numpy as np
import math

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


P = N[0]//2

suma = 0
for a in range(N[0]):
    suma = suma + (X[a] + P)**2

Q = (N[0]//2)+1
sumb = 0
for b in range(N[0]):
    sumb = sumb + (X[b] + Q)**2
if suma < sumb:
    print(suma)
else:
    print(sumb)
# Judge status: Wrong Answer
n=int(input())
s=input()
t=input()
ans=0
for i in range(n):
  print(i,s[i:],t[:n-i])
  if s[i:] == t[:n-i]:
    ans = max(n-i,ans)
print(2*n-ans)
# Judge status: Accepted
n = int(input())
sl = list(int(input()) for _ in range(n))
sl_sum = sum(sl)
sl.sort()

ans = 0

if sl_sum % 10 != 0:
    ans = sl_sum
else:
    for s in sl:
        if (sl_sum - s)%10 != 0:
            ans = max(sl_sum - s, ans)

print(ans)
# Judge status: Wrong Answer
k = int(input())
s = input()

if len(s) <= k:
    print(s)
else:
    print(s[:7] + '...')
# Judge status: Accepted
n,m=map(int,input().split())
l=list(map(int,input().split()))
if(sum(l)>=n):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
import sys
N, M = [int(x) for x in input().split()]

digits = {x+1: 0 for x in range(N)}
for _ in range(M):
    s, c = [int(x) for x in input().split()]
    if s == 1 and c == 0:
        if N != 1:
            print(-1)
            sys.exit()
    if digits.get(s, -1) not in [c, 0]:
        print(-1)
        sys.exit()
    digits[s] = c

result = 0
n = 0
for i in sorted(digits.keys(), reverse=True):
    result += digits[i] * (10 ** n)
    n += 1
print(result)
# Judge status: Accepted
n, c, k = map(int, input().split())
t = []    
for _ in range(n):
    t.append(int(input()))
t.sort()
first = t[0]
wait = 0
need = 1
for i in t:
    wait += 1
    if first + k < i or wait > c:
        need += 1
        wait = 1
        first = i
        continue
print(need)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))

mn=10**18
for i in range(-100,101):
    sm=0
    for k in range(n):
        sm+=(a[k]-i)**2
    mn=min(sm,mn)

print(mn)
# Judge status: Accepted

N = int(input())
L = sorted(list(map(int, input().split())))

from bisect import bisect_left

ans = 0
for c in range(2, N):
  for a in range(c-1):
    b_index = bisect_left(L, L[c]-L[a]+1)

    if b_index <= a:
      b_index = a + 1
    if c - b_index > 0:
      ans += c - b_index

print(ans)
# Judge status: Accepted
n = int(input())

colors = []

for i in range(n):
  a = int(input())
  if i == 0:
    colors.append(a)
    continue
  if colors[-1] >= a:
    colors.append(a)
  elif a > colors[0]:
    colors[0] = a
  else:
    l, r = 0, len(colors)
    while r-l > 1:
      k = (r+l)//2
      if a > colors[k]:
        r = k
      else:
        l = k
    if a > colors[l]:
      colors[l] = a
    else:
      colors[r] = a

print(len(colors))
# Judge status: Accepted
li = list(map(int,input().split()))
k = int(input())
li.sort()
ans = li[2]*(2**k)+li[0]+li[1]
print(ans)
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
if a == b and b == c:
  if a%2 == 0:
    print(-1)
  else:
    print(0)
else:
  ans = 0
  while a % 2 == 0 and b % 2 == 0:
    a1 = a
    b1 = b
    c1 = c
    a = (b1+c1)/2
    b = (a1+c1)/2
    c = (a1+b1)/2
    ans += 1
  print(ans)
# Judge status: Accepted
k, s = map(int, input().split())

ans = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if 0 <= z and z <= k:
            ans += 1
print(ans)
# Judge status: Accepted
a,b,c,d=[int(i) for i in raw_input().split()]
print max(a*c,a*d,b*c,b*d)
# Judge status: Accepted
import sys

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
M = sorted(A)
if M[-1] == M[-2]:
    for i in range(N):
        print(M[-1])
    sys.exit()
high_num = M[-1]
for i in range(N):
    if A[i] == high_num:
        print(M[-2])
    else:
        print(M[-1])
# Judge status: Accepted
H,N = map(int,input().split())
dp= [float("INF")]*(H+1)
dp[0]=0
for i in range(N):
    a,b = map(int,input().split())
    for j in range(1,H+1):
        dp[j] = min(dp[j],dp[max(j-a,0)]+b)

print(dp[-1])
# Judge status: Accepted
x, y = map(int, input().split())
l1= [1,3,5,7,8,10,12]
l2=[4,6,9,11]
l3=[2]
if x in l1 and y in l1:
    print('Yes')
elif x in l2 and y in l2 :
    print('Yes')
else :
    print('No')
# Judge status: Accepted
a = int(input())
b = int(input())
q =[1,2,3]
q.remove(a)
q.remove(b)
print(q[0])
# Judge status: Wrong Answer
a,b,k =map(int ,input().split())
n =[]
for i in range(1 ,100):
    if a %i ==0 and b %i ==0:
        n.append(i)
n.sort(reverse =True)
print(n[k-1])
# Judge status: Accepted
A,B,C=map(int,input().split())

if(A==B and (B==C and A==C)):
    print("No")

elif(A!=B and (B!=C and A!=C)):
    print("No")
else:
    print("Yes")
# Judge status: Accepted
r,g,b = input().split()
l = int(r+g+b)
print("YES" if l%4 == 0 else "NO")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(0, N, 2):
    if A[i] % 2 == 1:
        ans += 1

print(ans)
# Judge status: Accepted
def mycounter(d,i):
    if i in d:
        d[i]+=1
    else:
        d[i]=1
    return d
    
n=int(input())
a=list(map(int,input().split()))
d=dict()
for i in a:
    d=mycounter(d,i)
p=0
for i,j in d.items():
    if i<j:
        p+=j-i
    if i>j:
        p+=j
print(p)
# Judge status: Accepted
from collections import defaultdict

n, m = map(int, input().split())
yp = []
for i in range(m):
    p, y = map(int, input().split())
    yp.append((y, p, i))
yp = sorted(yp)

code = [0] * m
ctr = defaultdict(int)
for i in range(m):
    ctr[yp[i][1]] += 1
    x = ctr[yp[i][1]]
    code[yp[i][2]] = '{:06}{:06}'.format(yp[i][1], x)
for c in code:
    print(c)
# Judge status: Accepted
n,m=map(int,input().split())
ls=[list(map(int,input().split())) for _ in range(n)]
lc=[list(map(int,input().split())) for _ in range(m)]

for i in range(n):
    p=0
    ans=10**9
    for j in range(m):
        dis=abs(lc[j][1]-ls[i][1])+abs(lc[j][0]-ls[i][0])
        if ans>dis:
            ans=dis
            p=j+1
    print(p)
# Judge status: Wrong Answer
N, T = map(int, input().split())
A=[0]*N
B=[0]*N
for i in range(N):
    a,b=map(int,input().split())
    A[i]=a
    B[i]=b

count=0
for i in range(N):
    count=count+B[i]
    if count>=T:
        print(A[i])
        exit()
# Judge status: Accepted
n, m = map(int, input().split())

arr = [[] for _ in range(n)] 

p = [0] * m
y = [0] * m

for i in range(m):
    p[i], y[i] = map(int, input().split())
    arr[p[i]-1].append(y[i])    

for i in range(n):
    arr[i].sort()

import bisect
for i in range(m):
    num = bisect.bisect_left(arr[p[i]-1], y[i]) + 1
    a = str(p[i])
    b = str(num)
    print(a.zfill(6) + b.zfill(6))
# Judge status: Wrong Answer
x, a, b = map(int, input().split())
print(min([abs(x-a), abs(x-b)]))
# Judge status: Accepted
N, A, B = map(int, input().split())
S = input()
cnt = 0
cnt1 = 0
for i in range(len(S)):
    if S[i]=="a" or S[i]=="b":
        if S[i]=="a" and cnt<A+B:
            print("Yes")
            cnt+=1
        elif S[i]=="b"and cnt<A+B and cnt1<B:
            print("Yes")
            cnt+=1
            cnt1+=1
        else:
            print("No")
    else:
        print("No")
# Judge status: Accepted
n, m = map(int, input().split())
a = list(input().split())

for i in range(len(a)):
    n = n - int(a[i])

if n >= 0:
    print(n)
else:
    print(-1)
# Judge status: Wrong Answer
from functools import *
@lru_cache(maxsize=None)
def f(x):
  if x==1:return 1
  s=1000000000
  for u in [1]+[6**i for i in range(1,11)]+[9**i for i in range(1,11)]:
    if x-u>=1:
      s=min(s,f(x-u)+1)
  return s
for i in range(1,100001):f(i)
print(f(int(input())))
# Judge status: Accepted
from fractions import gcd
N = int(input())
ans = 1
for _ in range(N):
  t = int(input())
  ans = t * ans // gcd(t, ans)
print(ans)
# Judge status: Accepted
n,x,t=map(int,input().split(' '))
if n%x==0:
	print((n//x)*t)
else:
	print(((n//x)+1)*t)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
count = 0
for i in range(N):
    if A[i] % 2 != 0 and i%2!=0:
        count += 1
print(count)
# Judge status: Accepted
K = int(input())
problems = list(map(int,input().split()))

problems.sort()

divider = K // 2
ABC = problems[:divider]
ARC = problems[divider:]

print(ARC[0] - ABC[-1])
# Judge status: Accepted
from collections import Counter
n = int(input())
S = [input() for _ in range(n)]

count = Counter(S[0])
for s in S[1:]:
  c = Counter(s)
  count = count & c
  
ls = sorted(count.items())

ans = ""
for i, j in ls:
  ans += i * j
  
print(ans)
# Judge status: Accepted
import sys

n, m = map(int, sys.stdin.readline().split())

def main():
    if n >= m // 2: res = m // 2
    else: res = n + (m - 2 * n) // 4
    print(res)

if __name__ ==  '__main__':
    main()
# Judge status: Accepted
s = list(set(list(input())))

if len(s)%2 == 0:
    if ("N" in s and"S" in s) or ("E" in s and "W" in s):
        print('Yes')
    else:
        print('No')
else:
    print('No')
# Judge status: Accepted
w, a, b = map(int, input().split())
if a <= b and b <= a+w:
    print(0)
elif b <= a+w and a <= b:
    print(0)
else:
    print(min(abs(a-b-w), abs(a+w-b)))
# Judge status: Accepted
N = int(input())
H = list(map(int, input().split()))

prev = H[0]
flag = True
for i in range(N-1):
    now = H[-i-1]
    after = H[-i-2]
    if after - now > 1:
        flag = False
        break
    elif after - now == 1:
        H[-i-2] -= 1
    else:
        pass
print('Yes') if flag else print('No')
# Judge status: Accepted
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))

cnt = defaultdict(int)
ans = 0
for i, a in enumerate(A, start=1):
    ans += cnt[-a + i]
    cnt[a + i] += 1

print(ans)
# Judge status: Accepted
import itertools
a,b,c,d = list(input())


for ops in itertools.product(['+','-'],repeat=3):
  eq = a+ops[0]+b+ops[1]+c+ops[2]+d
  x = eval(eq)
  
  if x==7:
    break

answer = eq+'=7'
print(answer)
# Judge status: Accepted
def main():
    left, right, div = [int(x) for x in input().split()]
    ans = sum(x % div == 0 for x in range(left, right + 1))
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
if list(map(int,input().split())).sort()==[5,5,7]:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
s=input()
i=0
c=0
l=len(s)
while i<l:
 if i<l-2 and len(set(s[i:i+2])):c+=1;i+=2
 elif i<l-1 and len(set(s[i:i+1])):c+=1;i+=1
 i+=1
print(c)
# Judge status: Wrong Answer
NM = input().split()
A = input().split()
N = int(NM[0])
M = int(NM[1])
for j in range (N):
    A[j] =int(A[j])
for i in range(M):
    if int(A[i])<sum(A)/4*M:
        print("No")
        exit()
print("Yes")
# Judge status: Wrong Answer
n = input()
if n == 1:
    print(0)
if n == 0:
    print(1)
# Judge status: Accepted
K, X = map(int, input().split())
print("No" if 500*K < X else "Yes")
# Judge status: Accepted
H,A = map(int,input().split())
if H%A == 0:print(H//A)
else : print(H//A+1)
# Judge status: Accepted
from collections import deque

X, Y, A, B, C = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)

cand = sorted(p[:X] + q[:Y] + r, reverse=True)
print(sum(cand[:X+Y]))