peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
s = input()
if 1<=int(s[0:2])<=12 and 1<=int(s[2:4])<=12:
    print("AMBIGUOUS")
elif 1<=int(s[0:2])<=12:
    print("MMYY")
elif 1<=int(s[2:4])<=12:
    print("YYMM")
else:
    print("NA")
# Judge status: Accepted
#template
def inputlist(): return [int(j) for j in input().split()]
from collections import Counter
#template
#issueから始める
N,x = inputlist()
a = inputlist()
a.sort()
count=0
for i in range(N):
    x -=a[i]
    if x < 0:
        print(count)
        exit()
    count +=1
if x >0:
    count -=1
print(count)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
res=0
bk_a=-1
for i in range(n):
  res+=b[a[i]-1]
  if bk_a+1==a[i]:
    res+=c[bk_a-1]
  bk_a=a[i]
print(res)
# Judge status: Accepted
x,n,*p=map(int,open(0).read().split())
print(min({*range(999)}-{*p},key=lambda y:abs(y-x)))
# Judge status: Accepted
import math
A, B, C, D = map(int, input().split())
L = C * D //math.gcd(C, D)
x = (A - 1) - (A -1) // C - (A - 1) // D + (A - 1) //L
y = B - B // C - B // D + B // L
print(y - x)
# Judge status: Accepted
K, X = [int(_) for _ in input().split()]
if K*500 >= X:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
K, X = map(int,input().split())
A = ""
for i in range(X-K+1, X+K):
    A = A + str(i) + " "
print(A)
# Judge status: Accepted
A, B, C, D = map(int, input().split())
cnt = 0
for i in range(101):
    if A <= i < B and C <= i < D:
        cnt += 1
print(cnt)
# Judge status: Accepted
n,a,b = map(int,input().split())
if (b-a)%2==0:
  print((b-a)//2)
else:
  print(min((a-1)+1+(b-a-1)//2,(n-b)+1+(b-a-1)//2))
# Judge status: Wrong Answer
A, B = map(int, input().split())

if A >= 13:
    print(B)
elif A >= 6:
    print(B/2)
else:
    print(0)
# Judge status: Accepted
w,a,b = map(int,input().split())
a1 = a
a2 = a+w
b1 = b
b2 = b+w
if abs(b-a) > w:
    print(min(abs(b1-a2),abs(b2-a1)))

else:
    print(0)
# Judge status: Accepted
a,b=map(int,input().split())
x=(a+b)/2
if x.is_integer()==1:print(int(x))
else:print("IMPOSSIBLE")
# Judge status: Wrong Answer
n=int(input())
lst=list(map(int,input().split()))
cnt=0
for i in range(n):
  if i%2==1 and lst[i]%2==1:
    cnt+=1
print(cnt)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
if (a+b+c)%2==0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
q, h, s, d = map(int, input().split())
n = int(input())
h = min(q*2, h)
s = min(h*2, s)
if 2*s <= d:
  print(s*n)
else:
  if n%2==0:
    print(d*(n//2))
  else:
    print(d*(n//2)+s)
# Judge status: Accepted
a = input().split()
if int(a[0]) > 10:
    print(int(a[1]))
else:
    print(int(a[1]) + 100*(10 - int(a[0])))
# Judge status: Wrong Answer
a, b = map(int, input().split())
c = 10 * a + b
if int((c ** 0.5)) ** 2 == c:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import sys

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

N = int(readline())
m = map(int, read().split())
A, B = zip(*zip(m, m))

A, B = A[::-1], B[::-1]

x = 0
for a, b in zip(A, B):
    a += x
    y = (-a) % b
    x += y
print(x)
# Judge status: Wrong Answer
arr = input().split()
K = int(arr[0])
A = int(arr[1])
B = int(arr[2])

n = 1 + K

x = B
K -= A+1

temp = int(K / 2)

x += temp * abs(B-A)
K -= temp * 2

while K > 0:
	K -= 1
	x += 1

print(max(x, n))
# Judge status: Wrong Answer
N,K = map(int,input().split())
p = list(map(int,input().split()))

saidai = 0
base = sum(p[0:K])

for i in range(N-K+1):
	if i+K+1 < N:
		gokei = 0
		gokei = base - p[i] + p[i+K+1]
		if saidai < gokei:
				saidai = gokei

print((saidai+K)/2)
# Judge status: Accepted
N = int(input())
from collections import deque
import itertools
ans = deque()
l = []
r = deque()
for i in range(N):
  l.append(chr(97+i))
  r.append(l.copy())
  

p = [[[] for _ in range(N)] for _ in range(N)]
p[0][0].append('a')
for i in range(1,N):
  for j in r[i]:
    x = ord(j)-97
    for n,k in enumerate(p[i-1][max(0,x-1):],max(0,x-1)):
      for m in k:
        p[i][max(n,x)].append(m+j)


p = p[-1]
p = list(itertools.chain.from_iterable(p))
p.sort()
for q in p:
  print(q)
# Judge status: Wrong Answer
import math
def coordinate(x,y):
    return math.sqrt(x**2 + y**2)


def main():
    n, d = str(input()).split(' ')
    n,d = int(n), int(d)
    count = 0
    for i in range(n):
        x,y = str(input()).split()
        x, y = int(x), int(y)
        dist = coordinate(x,y)
        if int(dist) == d:
            count += 1
    print(count)

if __name__ == main():
    main()
# Judge status: Wrong Answer
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from collections import Counter

n = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
c = Counter(A)

k = 0
area = 1
for a,b in c.items():
    if b >1:
        area *= a
        k += 1
    if k > 1:
        print(area)
        exit()
print(0)
# Judge status: Wrong Answer
# C - Typical Stairs

MOD = 10 ** 9 + 7
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
dp = [0] * (N + 1)

def f(i):
    if dp[i] != None:
        return dp[i]
    else:
        if i in A:
            dp[i] = 0
        elif i < 2:
            dp[i] = 1
        else:
            dp[i] = (f(i - 1) + f(i - 2)) % MOD
        return dp[i]

print(f(N))
# Judge status: Accepted

import sys
A,B,K=map(int,input().split())
if((B-A) < K):
    for i in range(A,B+1):
        print(i)
    sys.exit()
ansmin=[i for i in range(A,A+K,1)]
ansmax=[i for i in range(B,B-K,-1)]

ans=ansmin+ansmax
ans=set(ans)
ans=sorted(ans)
for a in ans:
    print(a)
# Judge status: Accepted
a = input()
if len(a) == len(set(a)):
  print('yes')
else:
  print('no')
# Judge status: Accepted
a = input()
b = input()

c = a[::-1]

if b == c:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
c=[list(map(int,input().split())) for i in range(3)]
if (c[0][0]+c[1][1]+c[2][2])*2==c[0][1]+c[0][2]+c[1][0]+c[1][2]+c[2][0]+c[2][1]:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))
decided = [0 for _ in range(N+1)]

a.insert(0,0)

for i in range(N,0,-1):
    count = 0
    check = 2*i
    while check <= N:
        count = (count+decided[check])%2
        check += i
    if a[i] == 1 and count == 1:
        continue
    elif a[i] == 0 and count ==0:
        continue
    else:
        decided[i] = 1

print(sum(decided))
answer = [i for i in range(N+1) if decided[i]==1]

print(" ".join(list(str(i) for i in answer)))
# Judge status: Accepted
s=input()
count=s.count("B")
if count==3 or count==0:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
n,k=map(int,input().split())
a=list(map(int,input().split()))


for j in range(k):
    b=[0]*n
    for i in range(0,n):
        l=max(0,i-a[i])
        r=min(n-1,i+a[i])
        b[l]+=1
        if(r+1<n):
            b[r+1]-=1
    for i in range(1,n,1):
        b[i]+=b[i-1]
    if a==b:
        break
    a=b

print(' '.join(map(str,a)))
# Judge status: Wrong Answer
a=int(input())
b=str(input())
sum=0

riron_sum=b.count('R')*b.count('G')*b.count('B')
print(riron_sum)
for i in range(0,a):
    for n in range(0,a+1):
        j = i+n
        k = j+n
        #print(j)
        #print(k)
        if k>=a:
        	break

        if b[i]!=b[j] and b[j]!=b[k] and b[k]!=b[i]:
                riron_sum-=1

print(riron_sum)
# Judge status: Accepted
N=int(input())
A=input().split()
x=0
for i in range(N):
  if int(A[i])%2==0:
    if int(A[i])%5==0 or int(A[i])%3==0:
      x+=1
  else:
    x+=1
if x==N:
  print('APPROVED')
else:
  print('DENIED')
# Judge status: Wrong Answer
# https://atcoder.jp/contests/abc085/tasks/abc085_c

# N枚、Y円
N, Y = map(int, input().split())

for i in range(N + 1):
    for j in range(N + 1):
        
        z = N - (i + j)

        if z < 0:
            continue

        if i*1000 + j*5000 + z*10000 == Y:
            print(i, j, z)
            exit()

print(-1, -1, -1)
# Judge status: Wrong Answer
x,y,z=map(int,input().split())
x-=y
print(1+(x//(y+z)))
# Judge status: Accepted
N, *A = map(int, open(0).read().split())
B = sorted(A)
if B[-1] == B[-2]:
    for a in A:
        print(B[-1])
else:
    for a in A:
        if a != B[-1]:
            print(B[-1])
        else:
            print(B[-2])
# Judge status: Accepted
def main():
 num = int(input())
 print(int(num*(num+1)/2))
 
main()
# Judge status: Accepted
a,b = map(float,input().split())
a = int(a)
b = round(float(b)*100)
print((a*b)//100)
# Judge status: Accepted
H, N = map(int, input().split())
A=list(map(int, input().split()))

atack= sum(A)
if H-atack<=0:
    print("Yes")
elif H-atack>0:
    print("No")
# Judge status: Accepted
a = input()

if(a[2]==a[3] and a[4]==a[5]):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
import sys
readline = sys.stdin.readline

def main():
    N = int(readline())
    A = list(map(int, readline().rstrip().split()))
    for i in range(N-2):
        if A[i] < 0:
            A[i] *= -1
            A[i+1] *= -1
    
    if A[-2]*-1 + A[-1]*-1 > A[-2] + A[-1]:
        A[-2] *= -1
        A[-1] *= -1
    
    print(sum(A))


if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

pre_max = 0
ans = 0
for An in A:
    if pre_max <= An:
        pre_max = An
    else:
        ans += pre_max - An

print(ans)
# Judge status: Accepted
N=int(input())
an=map(int,input().split())
Cards=[]
for a in an:
    Cards.append(int(a))
SortedCards=sorted(Cards,reverse=True)
AliceCards=SortedCards[0::2]
BobsCards=SortedCards[1::2]
print(sum(AliceCards)-sum(BobsCards))
# Judge status: Accepted
import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
n,k=NM()
hi=10**9
lo=1
l=L()
def f(mi):
    x=0
    for i in l:
        if i<=mi:
            continue
        x+=(i+mi-1)//mi-1
    if x<=k:
        return True
    return False
while hi>=lo:
    mi=(hi+lo)//2
    if f(mi):
        hi=mi-1
    else:
        lo=mi+1
print(lo)
# Judge status: Wrong Answer
import math
S = int(input())

a = int(math.sqrt(S))
if S % a > 0:
  a += 1
b = a**2 - S
print(0, 0, a, b, 1, a)
# Judge status: Accepted
def main():
    suu="abcdefghijklmnopqrstuvwxyz"#26
    n=int(input())
    puts=""
    if n<27:#その数より小さい
        print(suu[n-1])
        return
    while True:
        temp=n%26
        n//=26
        puts=suu[temp-1]+puts
        if temp==0:#補正
            n-=1
        if n<27:
            puts=suu[n-1]+puts
            break
    print(puts)
if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n = int(input())
s = str(input())

max = 0
for i in range(n):
  max1 = s.count(s[i])
  if (max < max1):
    max = max1

print(max)
# Judge status: Wrong Answer
cand_num, tenka = map(int, input().split(" "))
candles = list(map(int, input().split(" ")))
mini = 10 ** 8

for i in range(cand_num - tenka + 1):
    if candles[i] * candles[tenka - 1] >= 0:
        temp = max(candles[i], candles[tenka + i - 1])
    else:
        temp = min(abs(candles[i]), abs(candles[tenka + i- 1])) * 2 + max(abs(candles[i]), abs(candles[tenka + i - 1]))
    mini = temp if mini > temp else mini
print(mini)
# Judge status: Accepted
S = input()

f = int(S[:2])
b = int(S[2:])

if 1 <= f <= 12 and 1 <= b <= 12:
    print('AMBIGUOUS')
elif 1 <= b <= 12:
    print('YYMM')
elif 1 <= f <= 12:
    print('MMYY')
else:
    print('NA')
# Judge status: Wrong Answer
N,M = map(int,input().split())

for i in range(M//2+1):
    if M//N < 2:
        break   
    M -= 2
    N += 1
if M<2:
    print(0)
else:
    print(N-1)
# Judge status: Accepted
N, K = map(int,input().split())
s = input()
res = 0
if s[0] == 'R' and s[1] == 'R':
    res += 1
for i in range(1,N-1):
    if s[i-1] == 'R' and s[i] == 'L':
        continue
    elif s[i+1] == 'L' and s[i] == 'R':
        continue
    res += 1
if s[N-1] == 'L' and s[N-2] == 'L':
    res += 1
res = min([N-1, res+2*K])
print(res)
# Judge status: Accepted
x = int(input())
count = 0

count = x//11*2
if 0 < x-count*11/2 <= 6:
    count += 1
elif 0 < x-count*11/2:
    count += 2
print(count)
# Judge status: Accepted
# 整数の入力
a, b, c = map(int, input().split())
# 合計17でないときNOを出力
if not (a+b+c == 17):
    print("NO")
    exit()
# 7を含まないときNOを出力
if not 7 in (a, b, c):
    print("NO")
    exit()
# 5を含まないときNOを出力、それ以外はYESを出力
if not 5 in (a, b, c):
    print("NO")
    exit()
else:
    print("YES")
# Judge status: Accepted
n = int(input())
nums = [int(x) for x in input().split()]
nums_v2 = []
nums_v3 = []

for i in range(len(nums)):
      if (i+1)%2 == 1:
            nums_v2.append(nums[i])

for i in range(len(nums_v2)):
      if nums_v2[i]%2 == 1:
            nums_v3.append(nums_v2[i])

print(len(nums_v3))
# Judge status: Wrong Answer
import bisect
def lis_broad_sence(A):
    INF = 10**9
    N=len(A)
    dp = [INF] * (N+1) 
    for a in A:
        idx = bisect.bisect_right(dp,a)
        dp[idx] = a

    answer = bisect.bisect_left(dp, INF)
    return answer
n = int(input())
seq = list(map(int,input().split()))
seq.reverse()
print(lis_broad_sence(seq))
# Judge status: Wrong Answer
x,a,b=map(int, input().split())
if abs(x-a)>abs(x-b):
  print('A')
else:
  print('B')
# Judge status: Accepted
n = int(input())
p_list = list(map(int, input().split()))

mi_p=1000000
count = 0
for p in p_list:
    if p < mi_p:
        count = count + 1
        mi_p = p

print(count)
# Judge status: Accepted
n=int(input())
p=list(map(int,input().split()))

l=-1
arr=[]
for i in range(n):
    if p[i]==i+1:
        arr.append(i)
ans=len(arr)
i=0
while i<len(arr)-1:
    if arr[i+1]==arr[i]+1:
        ans-=1
        i+=1
    i+=1
print(ans)
# Judge status: Accepted
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
M = min(100, K + 1)

DP = [[0] * N for _ in range(M)]

for i in range(N):
  DP[0][i] = A[i]

for i in range(1, M):
  for j in range(N):
    DP[i][max(0, j - DP[i-1][j])] += 1
    t = j + DP[i-1][j] + 1
    if t < N:
      DP[i][t] -= 1
  for j in range(1, N):
    DP[i][j] += DP[i][j-1]

print(" ".join(map(str, DP[-1])))
# Judge status: Accepted
n=int(input())
con=0
for i in range(1,n+1):
  s=len(str(i))
  if s%2!=0:
    con+=1
print(con)
# Judge status: Accepted
K=int(input())
def waru(K):
    a=[]
    if K%2==0 or K%5==0:
        print("-1")
        return
    a.append(7%K)
    for i in range(1,K):
        a.append((10*a[i-1]+7)%K)
    for i in range(K):
        if a[i]==0:
            print(i+1)
            return
    print(-1)
waru(K)
# Judge status: Accepted
n = int(input())

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

cnt = 0
ave = sum(a)/2

for i in range(n):
    cnt += a[i]
    if cnt >= ave:
        ans = min(cnt*2-ave*2, ave*2-(cnt-a[i])*2)
        break

print(int(ans))
# Judge status: Accepted
n = input()
a = ["Sunny", "Cloudy", "Rainy", "Sunny"]
print(a[a.index(n) + 1])
# Judge status: Accepted
def main():
    N = [int(x) for x in input()]
    dp0 = 0
    dp1 = 1
    for n in N:
        # そのまま払う
        a = min(dp0 + n, dp1 + 10 - n)
        # 1多めに払う
        b = min(dp0 + n + 1, dp1 + 10 - (n+1))
        dp0, dp1 = a, b
        
    print(dp0)
 
 
if __name__ == '__main__':
    main()
# Judge status: Accepted
#152 Low Elements
n = int(input())
seq = list(map(int,input().split()))
c = []
cnt = 0
for i in range(n):
    if i == 0:
        cnt+=1
        c.append(seq[0])
    else:
        if c[-1] >= seq[i]:
            cnt += 1
            c.append(seq[i])
        
print(cnt)
# Judge status: Accepted
N = int(input())
S = input()

answer = 0
for i in range(1,N):
    X = set(S[:i])
    Y = set(S[i:])
    answer = max(answer, len(X&Y))
print(answer)
# Judge status: Wrong Answer
a=int(input())
b=[int(input()) for i in range(a)]
c=sum(b)
d=0
if c%10==0:
  for i in range(a):
    if b[i]%10!=0:
      print(c-b[i])
      break
    if b[i]%10==0:
      d=d+1
      if d==a:
        print(0)
        break
else:
  print(c)
# Judge status: Accepted

from re import search
def myAnswer(N:int,A:int,B:int,C:int,D:int,S:str) -> str:
   if (search(r'##',S[A-1:max(C,D)])): return "No"
   if(C > D):
      return "Yes" if (search(r'\.\.\.',S[B - 2:D+1])) else "No"
   return "Yes"

def modelAnswer():
   return
def main():
   N,A,B,C,D = map(int,input().split())
   S = input()
   print(myAnswer(N,A,B,C,D,S))
if __name__ == '__main__':
   main()
# Judge status: Accepted
num = input()

op_count = 3

for i in range(2**op_count):
    op = ["-"] * op_count
    for j in range(op_count):
        if (i >> j & 1):
            op[j] = "+"

    equ = ""

    for n_i,o_i in zip(num,op + [""]):
        equ += n_i + o_i
    if(eval(equ) == 7):
        print(equ + "=7") 
        break
# Judge status: Accepted
N = input()
flag = 0
for i in N:
  if i == "7":
    print("Yes")
    flag = 1
    break
if flag == 0:
  print("No")
# Judge status: Accepted
n,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]

a.sort()
cnt=0
ans=0
for i in range(n):
    m-=a[i][1]
    if m>=0:
        ans+=a[i][0]*a[i][1]
    else:
        ans+=(m+a[i][1])*a[i][0]
        print(ans)
        exit()
print(ans)
# Judge status: Accepted
N=int(input())
A=list(map(int, input().split()))

def attack(lst):
    attacker=min(lst)
    position=lst.index(attacker)
    temp=[]
    for i in range(len(lst)):
        if i!=position:
            if lst[i] % attacker!=0:
                temp.append(lst[i]%attacker)
        else:
            temp.append(lst[i])
    return temp

while len(A)>1:
    A=attack(A)
    #print(A)
print(A[0])
# Judge status: Accepted
i = input()
if i[-4]==i[-3] and i[-2]==i[-1]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N, X = map(int, input().split())
L = list(map(int, input().split()))

ans = 1
d = 0
for x in L:
    d = d + x
    if d <= X :
        ans += 1

print(ans)
# Judge status: Wrong Answer
N=input()
j_count=0
for i in range(0,3):
    if N[i]==N[i+1]:
        j_count+=1
if j_count>=2:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
s=list(input())
if "a" and "b" and "c" in s:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
# input
S = list(input())

# check
print(S.count(1))
# Judge status: Accepted
a=input().split()
a[0],a[1],a[2]=a[2],a[0],a[1]
print(" ".join(a))
# Judge status: Accepted
a,b,n=map(int,input().split())
if n>=b:
    print(int(a*(b-1)/b))
else:
    print(int(a*(n%b)/b))
# Judge status: Wrong Answer
a=[0]*10**7
a[1]=int(input())
cnt=dict()

def f(v):
  if v%2:
    return 3*v+1
  else:
    return v//2

for i in range(2,10**7+1):
  a[i] = f(a[i-1])
  if a[i] in cnt:
    print(i)
    break
  else:
    cnt[a[i]]=0
# Judge status: Accepted
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))
from fractions import gcd
from functools import reduce
def lcm_base(x, y):
    return (x * y) // gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
print(lcm_list(T))
# Judge status: Accepted
import sys
N = int(sys.stdin.readline())
S = [sys.stdin.readline().rstrip() for i in range(N)]
print(len(set(S)))
# Judge status: Accepted
N = int(input())
print((N+ 1)//2)
# Judge status: Accepted
import numpy as np

K, X = map(int, input().split(' '))

l = np.zeros(2*K-1)

for i in range(2*K-1):
    l[i] = X - (K-1-i)

for i in l:
    print(int(i), end=' ')
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

A, B = mapint()
if 1<=A<=9 and 1<=B<=9:
    print(A*B)
else:
    print(-1)
# Judge status: Wrong Answer
N = int(input())
ans = float('inf')
ls = []
l = [1]
tmp = 6
while tmp <= 100000:
    l += [tmp]
    tmp *= 6

tmp = 9
while tmp <= 100000:
    l += [tmp]
    tmp *= 9

dp = [float('inf')]*(N+1)
dp[1] = 1
for i in range(N+1):
    for n in l:
        if i-n>=0:
            dp[i] = min(dp[i], dp[i-n]+1)
print(dp[N])
# Judge status: Accepted
n,m = map(int,input().split())
ans = [False]*n
cnt = [1]*n
ans[0] = True
for i in range(m):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    cnt[y] += 1
    if ans[x]:
        ans[y] = True
    cnt[x] -= 1
    if cnt[x]==0:
        ans[x] = False
c = 0
for i in ans:
    if i:
        c += 1

print(c)
# Judge status: Accepted
from collections import Counter

n, k = map(int, input().split())
a = input().split()
c = sorted(Counter(a).values(), reverse=True)

print(max(0, sum(c[k:])))
# Judge status: Wrong Answer
import numpy as np
a, b, x = map(int,input().split())
l = (2 * x) / (a * b)
print(180 / np.pi * np.arctan(b / l))
# Judge status: Wrong Answer
import sys

x = int(sys.stdin.readline())
n = x // 11
r = x % 11
if r <= 5:
    print(2*n + 1)
else:
    print(2 * (n+1))
# Judge status: Wrong Answer
S=str(input())
M=['A','C','G','T']
c=0
cmax=0
for i in range(len(S)):
  if S[i] in M:
    c+=1
  else:
    if c>cmax:
      cmax=c
    c=0
print(cmax)
# Judge status: Accepted
#!/usr/bin/env python

def main():
    S = input()

    for i in range(1 << 3):
        operator = ["-", "-", "-"] 
        for j in range(3):
            if ((i >> j) & 1):
                operator[j] = "+"
        formula = ""
        for s, op in zip(S, operator + [""]):
            formula += s + op
        if eval(formula) == 7:
            print(formula + "=7")
            break

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n = int(input())
a = [int(i) for i in input().split()]
even= 0
odd = 0
for i in range(n):
    if a[i]%4 == 0:
        even +=1
    else:
        odd+=1
if (even)*2 >=odd:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n=int(input())
mod=10**9+7
print(pow(10,n,mod)-2*pow(9,n,mod)+pow(8,n,mod))
# Judge status: Accepted
s = input()*2
t = input()
if t in s:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
ab = [tuple(map(int,input().split())) for i in range(n)]
ab.sort(key = lambda x:x[1])

t = 0
for a,b in ab:
    t +=a
    if t > b:
        print('No')
        exit()
print('Yes')
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))

count = [0] * (10**5 + 1)

for x in a:
    count[x - 1] += 1
    count[x] += 1
    count[x + 1] += 1
print(max(count))
# Judge status: Wrong Answer
a, b, c = input().split()
if a <= c <= b:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n = int(input())
robot = [tuple(map(int, input().split())) for _ in range(n)]
robot = [(x - l, x + l) for x, l in robot]
robot.sort()

ans = 0
last = float('inf')
for l, r in robot:
  if last >= r:
    ans += 1
    last = l
    
print(ans)
# Judge status: Wrong Answer
n = int(input())

s = input()
t = input()

if s == t: print(n)
else:
  s = s[::-1]
  count = 2 * n
  for i in range(0, n):
    if s[i] == t[i]: count -= 1
  print(count)
# Judge status: Accepted
N,K,Q = map(int,input().split())
A = [K-Q]*(N+1)
for i in range(0,Q,1):
    A[int(input())]+=1
for i in range(1,N+1,1):
    print("Yes" if A[i] > 0 else "No")
# Judge status: Accepted
from collections import deque

s = input()
q = int(input())

deq = deque([s])
flag = 1
for i in range(q):
    query = input().split()
    if query[0]==str(1):
        flag*=-1 
    if query[0]==str(2):
        x = 1 if query[1]==str(1) else -1
        if flag*x==1:
            deq.appendleft(query[2])
        else:
            deq.append(query[2])

if flag==-1:
    print(''.join(deq)[::-1])
else:
    print(''.join(deq))
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

prev = a[0]
mon = 1000
stc = 0

for i in range(1, n):
    #print(prev)
    if prev < a[i]:
        stc = mon // prev
        mon = mon - stc * prev
        #print("stc = {} mon = {}" .format(stc, mon))
    elif prev > a [i]:
        mon = mon + stc * prev
        stc = 0
        #print("stc = {} mon = {}" .format(stc, mon))
    prev = a[i]

if stc != 0:
    mon = mon + stc * a[n - 1]

print(mon)
# Judge status: Accepted
C1 = input()
C2 = input()

if C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
n,m = map(int, input().split())
flag = 0
if(n%2==1):
	for i in range(m):
		print(i+1,n-i)
else:
	for i in range(m):
		if(n-i-i-1 == int(n/2)):
			flag = 1
		if(flag == 1):
			print(i+1,n-i-1)
		else:
			print(i+1,n-i)