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

def main():
    input1 = input()
    N = int(input1)
    S = []
    result = 0
    for i in range(N):
        input2 = input()
        if not (str(input2)) in S:
            result += 1
            S.append(str(input2))
    
    print(result)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    input1 = input()
    N = int(input1)
    S = [0]*N
    result = 0
    for i in range(N):
        input2 = input()
        S[i] = str(input2)

    set_S = []
    set_S = set(S)
    result = len(set_S)
    
    print(result)

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

H, W, D = map(int, input().split())
A = [0] * H * W
for i in range(H):
    temp = list(map(int, input().split()))
    for j in range(len(temp)):
        A[temp[j] - 1] = (i + 1, j + 1)

Q = int(input())
L = []
R = []
for _ in range(Q):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)


def consumption(point_A, point_B):
    return abs(point_A[0] - point_B[0]) + abs(point_A[1] - point_B[1])


for i in range(Q):
    power = 0
    for j in range(int((R[i] - L[i]) / D)):
        power += consumption(A[L[i] + j * D - 1], A[L[i] + (j + 1) * D - 1])
        #print("{}->{}".format(A[L[i] + j * D - 1], A[L[i] + (j + 1) * D - 1]))
    print(power)


### FIXED CODE ###

H, W, D = map(int, input().split())
A = [0] * H * W
for i in range(H):
    temp = list(map(int, input().split()))
    for j in range(len(temp)):
        A[temp[j] - 1] = (i + 1, j + 1)

Q = int(input())
L = []
R = []
for _ in range(Q):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)


def consumption(point_A, point_B):
    return abs(point_A[0] - point_B[0]) + abs(point_A[1] - point_B[1])


X = []
for i in [D] + list(range(1, D)):
    power = 0
    x = [0]
    for j in range(int((H * W - i) / D)):
        power += consumption(A[i - 1 + j * D], A[i - 1 + (j + 1) * D])
        x.append(power)
        #print("{}->{}".format(A[i - 1], A[i - 1 + (j + 1) * D]))
    X.append(x)
# print(X)
for i in range(Q):
    k = L[i] % D
    if k == 0:
        l = int((L[i] - D) / D)
        r = int((R[i] - D) / D)
    else:
        l = int((L[i] - k) / D)
        r = int((R[i] - k) / D)
    #print(X[k], l, r)
    print(X[k][r] - X[k][l])
### BUGGY CODE ###

s = input()
K = int(input())
substring = []
loong = False
for i in range(len(s)):
    for j in range(i, len(s)):
        if len(s[i:j+1]) <= 5:
            substring.append(s[i: j + 1])
substring = list(set(substring))
substring.sort()                
print(substring[K-1])

### FIXED CODE ###

s = input()
K = int(input())
substring = []
for i in range(len(s)):
    for j in range(i, i+5):
        substring.append(s[i: j + 1])
substring = list(set(substring))
substring.sort()                
print(substring[K-1])
### BUGGY CODE ###

#!/usr/bin/env python3

import sys
sys.setrecursionlimit(10**6)

def operation(s,memo=-1,ans=0):
    if len(s) <= 0:
        return ans
    elif s[0] == memo == "0": #変えるパターン
        return operation(s[1:],"1",ans+1)
    elif s[0] == memo == "1": #変えるパターン
        return operation(s[1:],"0",ans+1)
    else:
        return operation(s[1:],s[0],ans)

def solve(s):
    return min(operation(s,"0"),operation(s,"1"))

def main():
    S = input()
    print(solve(S))


if __name__ == '__main__':
    main()

### FIXED CODE ###

#!/usr/bin/env python3

import sys
sys.setrecursionlimit(10**6)

def operation(s,f):
    c = 0
    for i in range(len(s)):
        if (s[i] == f and i % 2 == 1) or (s[i] != f and i % 2 == 0):
            c += 1
    return c

def solve(s):
    return min(operation(s,"0"),operation(s,"1"))

def main():
    S = input()
    print(solve(S))


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

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())
ans = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        for l in range(1, k+1):
            ans += gcd(i, j, l)

print(ans)

### FIXED CODE ###

import math

k = int(input())
ans = 0
chk_list = []
for i in range(1, k+1):
    for j in range(1, k+1):
        chk = math.gcd(i, j)
        chk_list.append(chk)

for l in range(1, k+1):
    for h in chk_list:
        ans += math.gcd(l, h)

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

import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

H,W = map(int,input().split())
INF = 10**18
q = []

d = [[0]*(W+2)] + [[0]+[INF]*W+[0] for _ in range(H)] + [[0]*(W+2)]# '#'からの距離

for i in range(1,H+1):
  for j,c in enumerate(input(),1):
    if c == '#':
      d[i][j] = 0
      q.append((i,j))

ans = -1
qq = []
while q:
  ans += 1
  for x,y in q:
    for dx,dy in [(0,1),(0,-1),(1,0),(-1,0)]:
      xx = x+dx
      yy = y+dy
      if d[xx][yy] == INF:
        d[xx][yy] = 0
        qq.append((xx,yy))
  q = qq
  qq = []
  
print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

H,W = map(int,input().split())
INF = 10**18
q = []

visited = [[True]*(W+2)]
visited += [[True] + [x == '#' for x in input().rstrip()] + [True] for _ in range(H)]
visited.append([True]*(W+2))
  
for i in range(1,H+1):
  for j in range(1,W+1):
    if visited[i][j]:
      q.append((i,j))

moves = [(0,1),(0,-1),(1,0),(-1,0)]

ans = -1
while q:
  qq = []
  ans += 1
  for x,y in q:
    if not visited[x-1][y]:
      visited[x-1][y] = True
      qq.append((x-1,y))
    if not visited[x+1][y]:
      visited[x+1][y] = True
      qq.append((x+1,y))
    if not visited[x][y-1]:
      visited[x][y-1] = True
      qq.append((x,y-1))
    if not visited[x][y+1]:
      visited[x][y+1] = True
      qq.append((x,y+1))
  q = qq
  
print(ans)
### BUGGY CODE ###

n = input()
length = len(n)
mod = 10 ** 9 + 7

cnt = 1
j = n.count("1")

for digit, num in enumerate(n[::-1], 1):
    if num == "1":
        j -= 1
        cnt += (3 ** (digit - 1) + 1) * 2 ** j
        cnt %= mod

print(cnt)


### FIXED CODE ###

def main():

    n = input()
    length = len(n)
    mod = 10 ** 9 + 7

    cnt = 1
    j = n.count("1")

    for digit, num in enumerate(n[::-1], 1):
        if num == "1":
            j -= 1
            cnt += (pow(3, digit - 1, mod) + 1) * pow(2, j, mod)
            cnt %= mod

    print(cnt)


main()
### BUGGY CODE ###

def main():
    N, K = map(int, input().split())
    XY = (tuple(map(int, input().split())) for _ in [0] * N)

    x = [0] * N
    y = [0] * N
    for i, (j, k) in enumerate(XY):
        x[i] = j
        y[i] = k

    ans = float('inf')
    for xi in range(N):
        for xj in range(N):
            if x[xi] >= x[xj]: continue
            for yi in range(N):
                for yj in range(N):
                    if y[yi] >= y[yj]: continue
                    cnt = 0
                    for i in range(N):
                        if x[xi] <= x[i] <= x[xj] and y[yi] <= y[i] <= y[yj]:
                            cnt += 1
                    if cnt >= K:
                        ans = min(ans, (x[xj] - x[xi]) * (y[yj] - y[yi]))

    print(ans)

main()


### FIXED CODE ###

def main():
    N, K = map(int, input().split())
    XY = (tuple(map(int, input().split())) for _ in [0] * N)

    x = [0] * N
    y = [0] * N
    for i, (j, k) in enumerate(XY):
        x[i] = j
        y[i] = k

    ans = float('inf')
    for xi in range(N):
        for xj in range(N):
            if x[xi] >= x[xj]: continue
            for yi in range(N):
                for yj in range(N):
                    if y[yi] >= y[yj]: continue
                    cnt = 0
                    for i in range(N):
                        if x[xi] <= x[i] <= x[xj] and y[yi] <= y[i] <= y[yj]:
                            cnt += 1
                    if cnt >= K:
                        ans = min(ans, (x[xj] - x[xi]) * (y[yj] - y[yi]))

    print(ans)

main()
### BUGGY CODE ###

from math import ceil
n, h = map(int, input().split())
a = []
b = []
for i in range(n):
  p, q = map(int, input().split())
  a.append(p)
  b.append(q)
b.sort(reverse=1)
ans=0
m=max(a)
while(h>0 and len(b) != 0):
  if b[0] < m:
    break
  h-=b[0]
  b.pop(0)
  ans+=1
if h>0:
  ans+=ceil(h/m)
print(ans)

### FIXED CODE ###

from math import ceil
n, h = map(int, input().split())
a = []
b = []
for i in range(n):
  p, q = map(int, input().split())
  a.append(p)
  b.append(q)
b.sort(reverse=1)
ans=0
m=max(a)
for i in b:
  if i < m or h<=0:
    break
  h-=i
  ans+=1
if h>0:
  ans+=ceil(h/m)
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3
import collections
import copy
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

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

if 1 in A:
    if A.count(1) == 1:
        print(1)
    else:
        print(0)
    exit()

ret = 0

D = collections.Counter(A)
D2 = copy.copy(D)


for k, v in D2.items():
    if v != 1:
        D.pop(k)
    elif is_prime(k):
        D.pop(k)
        ret += 1



A = list(set(A))

for a in D.keys():
    f = make_divisors(a)
    flag = True
    for f2 in f[2:]:
        if D2[f2] == 0: continue
        else: flag = False
    if flag: ret += 1


print(ret)


### FIXED CODE ###

#!/usr/bin/env python3

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

M = 10 ** 6  + 5
dp = [0]*(M)

for a in A:
    index = 1
    if dp[a] != 0:
        dp[a] = 2
        continue
    for i in range(a, M, a):
        dp[i] += 1

ret = 0
for a in A:
    if dp[a] == 1: ret +=1

print(ret)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

R, C, K = map(int, input().split())
rcvs = [list(map(int, input().split())) for _ in range(K)]

rcvs = rcvs


for i in range(len(rcvs)):
    rcvs[i][0] -= 1
    rcvs[i][1] -= 1

rewards = [[0 for _ in range(C)] for _ in range(R)]


for rcv in rcvs:
    rewards[rcv[0]][rcv[1]] = rcv[2]

dp = [[[0 for _ in range(4)] for _ in range(C+1)] for _ in range(R+1)]
answer = 0

for i in range(R):
    for j in range(C):
        reward = rewards[i][j]
        dp[i+1][j+1][0] = max(dp[i][j+1])
        dp[i+1][j+1][1] = dp[i+1][j+1][0] + reward
        
        for k in range(4): # move downside without selecting
            candidate = dp[i+1][j][k]
            dp[i+1][j+1][k] = max(dp[i+1][j][k], dp[i+1][j+1][k])
        if reward > 0:
            for k in range(3):
                dp[i+1][j+1][k+1] = max(dp[i+1][j][k]+reward,dp[i+1][j+1][k+1])
print(max(dp[-1][-1]))


### FIXED CODE ###

import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8
import sys

R, C, K = map(int, input().split())
rcvs = [list(map(int, input().split())) for _ in range(K)]
rcvs = np.array(rcvs, dtype=np.int64)

@njit(i8(i8[:,:]), cache=True)
def main(rcvs):
    rewards = np.zeros((R, C), dtype=np.int64)
    
    for i in range(len(rcvs)):
        rewards[rcvs[i][0]-1][rcvs[i][1]-1] = rcvs[i][2]
    
    dp = np.zeros((R+1, C+1, 4), dtype=np.int64)
    
    for i in range(R):
        for j in range(C):
            reward = rewards[i][j]
            dp[i+1][j+1][0] = max(dp[i][j+1])
            dp[i+1][j+1][1] = dp[i+1][j+1][0] + reward
            
            for k in range(4): # move downside without selecting
                dp[i+1][j+1][k] = max(dp[i+1][j][k], dp[i+1][j+1][k])
            if reward > 0:
                for k in range(3):
                    dp[i+1][j+1][k+1] = max(dp[i+1][j][k]+reward,dp[i+1][j+1][k+1])
    return max(dp[-1][-1])

print(main(rcvs))
### BUGGY CODE ###

import queue

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

a = []
b = []

for i in range(m):
	s, t = map(int, input().split())
	a.append(s-1)
	b.append(t-1)

#各部屋から行ける部屋
c = [[] for i in range(n)]

for i in range(m):
	c[a[i]].append(b[i])
	c[b[i]].append(a[i])

q = queue.Queue()
q.put(0)
f = []

#部屋1からの距離
d = [10**6]*n
d[0] = 0
ans = [0]*n
while not q.empty():
	x = q.get()
	if not(x in f):
		for i in c[x]:
			if not(i in f):
				q.put(i)
			if d[x]+1 < d[i]:
				d[i] = d[x]+1
				ans[i] = x+1
			
		f.append(x)

print('Yes')
for i in range(1,n):
	print(ans[i])

### FIXED CODE ###

import queue

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

a = []
b = []

for i in range(m):
	s, t = map(int, input().split())
	a.append(s-1)
	b.append(t-1)

#各部屋から行ける部屋
c = [[] for i in range(n)]

for i in range(m):
	c[a[i]].append(b[i])
	c[b[i]].append(a[i])

q = queue.Queue()
q.put(0)

#部屋1からの距離
inf = 10**8
d = [inf]*n
d[0] = 0
ans = [0]*n

while not q.empty():
	x = q.get()
	for i in c[x]:
		if d[i]==inf:
			q.put(i)
			d[i] = d[x]+1
			ans[i] = x+1

print('Yes')
for i in range(1,n):
	print(ans[i])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
from collections import deque

from sys import setrecursionlimit

setrecursionlimit(1000000)

INF = float("inf")
# Input#
# n = int(input())
n, m = map(int, input().split())
# a = list(map(int, input().split()))

d = deque()
d_tmp = deque()
x = [-1]
y = [-1]

for i in range(m):
    x_in, y_in = map(int, input().split())
    x.append(x_in)
    y.append(y_in)
    d.append((x_in, y_in))

memo = [-1] * (n + 1)
ans = -1


def dp(i):
    global ans
    if memo[i] == -1:
        ret = 0
        for x_in, y_in in d:
            if x_in == i:
                tmp = dp(y_in) + 1
                if tmp > ret:
                    ret = tmp
        memo[i] = ret
        if ret > ans:
            ans = ret
        return ret
    else:
        return memo[i]


for i, _ in d:
    if memo[i] == -1:
        dp(i)

print("{}".format(ans))


### FIXED CODE ###

# -*- coding: utf-8 -*-
from collections import deque

from sys import setrecursionlimit

setrecursionlimit(1000000)

INF = float("inf")
# Input#
# n = int(input())
n, m = map(int, input().split())
# a = list(map(int, input().split()))

d = deque()
d_tmp = deque()
x = [-1]
y = [[-1] for _ in range((n + 1))]

for _ in [0] * m:
    x_in, y_in = map(int, input().split())
    #    x.append(x_in)
    y[x_in].append(y_in)
    d.append((x_in, y_in))

memo = [-1] * (n + 1)
ans = -1


def dp(i):
    global ans
    if memo[i] == -1:
        ret = 0
        for x_in in y[i][1:]:
            tmp = dp(x_in) + 1
            if tmp > ret:
                ret = tmp
        memo[i] = ret
        if ret > ans:
            ans = ret
        return ret
    else:
        return memo[i]


for i, _ in d:
    if memo[i] == -1:
        dp(i)

print("{}".format(ans))
### BUGGY CODE ###

n = int(input())
c = input()
arr = []
for i in range(n + 1):
  a =  c[:i].count('W')
  b = c[i:].count('R')
  arr.append(max(a, b))
ans = min(arr)
print(ans)

### FIXED CODE ###

n = int(input())
c = input()
c = list(c)
arr = []
a = 0
b = c.count('R')
arr.append(max(a, b))
for i in range(n):
  if c[i] == 'W':
    a += 1
  elif c[i] == 'R':
    b -= 1
  arr.append(max(a, b))
ans = min(arr)
print(ans)
### BUGGY CODE ###

s = input()
k = int(input())
sub = []
num = len(s)
for i in range(num):
    for j in range(i, num):
        sub.append(s[i:j+1])
sub = list(set(sub))
sub.sort()
print(sub[k-1])

### FIXED CODE ###

s = input()
k = int(input())
sub = []
for i in range(len(s)):
    for j in range(i, i+5):
        sub.append(s[i:j+1])
sub = list(set(sub))
sub.sort()
print(sub[k-1])
### BUGGY CODE ###

import collections
import sys
import numpy as np
import copy
sys.setrecursionlimit(1000000000)
n = int(input())
a = list(map(int,input().split()))
A = collections.Counter(a)
li = []
for key,val in A.items():
    li.append([key,val])
temp = li[:]
for i in range(n):
    temp = li[:]
    ans = 0
    for j in range(len(temp)):
        if a[i] == temp[j][0]:
            temp[j][1] -= 1
            break
    for j in range(len(temp)):
        ans += ((temp[j][1])*(temp[j][1]-1))//2
    for j in range(len(temp)):
        if a[i] == temp[j][0]:
            temp[j][1] += 1
            break
    print(ans)

### FIXED CODE ###

import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

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

#ひとつものぞかず、同じ数のボールをとるのは？
c = collections.Counter(a)
maxa = 0
item = [0 for i in range(max(a))]
for key,value in c.items():
    item[key-1] = value
    maxa += (value)*(value-1)//2
for i in range(len(a)):
    d = (item[a[i]-1])*(item[a[i]-1]-1)//2-(item[a[i]-1]-1)*(item[a[i]-1]-2)//2
    print(maxa-d)
### BUGGY CODE ###

n,k=[int(j) for j in input().split()]
a=[int(j) for j in input().split()]
a.sort()
lm=[]
lp=[]
lz=[]
for i in a:
    if i<0:
        lm.append(i)
    elif i==0:
        lz.append(i)
    else:
        lp.append(i)
np=len(lp)
nm=len(lm)
nz=len(lz)
import bisect
import math
def f(x):
    c=0
    if x>=0:
        c+=nz*n
    for i in lp:
        c+=bisect.bisect_right(a,x//i)
    for i in lm:
        c+=n-bisect.bisect_right(a,(-x-1)//(-i))
    for i in a:
        if i**2<=x:
            c-=1
    return c//2

left=-10**20
right=10**20
while right-left>1:
    mid=(left+right)//2
    if f(mid)>=k:
        right=mid
    else:
        left=mid
print(right)





### FIXED CODE ###

n,k=[int(j) for j in input().split()]
from numpy import *
a=array([int(j) for j in input().split()])
a.sort()
lm=a[a<0]
lp=a[a>0]
lz=a[a==0]
np=len(lp)
nm=len(lm)
nz=len(lz)

import bisect
import math
def f(x):
    c=0
    if x>=0:
        c+=nz*n
    c+=searchsorted(a,x//lp,side="right").sum()
    c+=(n-searchsorted(a,(-x-1)//(-lm),side="right")).sum()
    c-=count_nonzero(a*a<=x)
    return c//2

left=-10**20
right=10**20
while right-left>1:
    mid=(left+right)//2
    if f(mid)>=k:
        right=mid
    else:
        left=mid
print(right)
### BUGGY CODE ###

N = int(input())
X = input()


def popcount(x):
    return x.count('1')


def f(x):
    cnt = 0
    while '1' in x:
        x = bin(int(x, base=2) % popcount(x))[2:]
        cnt += 1

    return cnt


def rev(c):
    if c == '0':
        return '1'
    else:
        return '0'


for i in range(N):
    xi = X[:i] + rev(X[i]) + X[i + 1:]
    print(f(xi))


### FIXED CODE ###

from functools import lru_cache

N = int(input())
X = input()


@lru_cache(maxsize=None)
def popcount(x):
    return x % bin(x).count('1')


def f(x):
    cnt = 1
    while x > 0:
        x = popcount(x)
        cnt += 1

    return cnt


count = X.count('1')
mod_one = count - 1
if mod_one == 0:
    mod_one = 1
mod_zero = count + 1
ones = [1 % mod_one]
zeros = [1 % mod_zero]
x_mod_one = 0 if X[-1] == '0' else 1 % mod_one
x_mod_zero = 0 if X[-1] == '0' else 1 % mod_zero

for xi in reversed(X[:-1]):
    ones.append(ones[-1] * 2 % mod_one)
    zeros.append(zeros[-1] * 2 % mod_zero)
    if xi == '1':
        x_mod_one += ones[-1]
        x_mod_one %= mod_one
        x_mod_zero += zeros[-1]
        x_mod_zero %= mod_zero

ones = list(reversed(ones))
zeros = list(reversed(zeros))

for i in range(N):
    if count == 1 and X[i] == '1':
        print(0)
    elif X[i] == '1':
        x = (x_mod_one - ones[i]) % mod_one
        print(f(x))
    else:
        x = (x_mod_zero + zeros[i]) % mod_zero
        print(f(x))
### BUGGY CODE ###

x = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

divisors = make_divisors(x)

for divisor in divisors:
  for a in range(100000):
    b = a - divisor
    if (a**5 - b**5 == x):
      print(a, b)
      break

### FIXED CODE ###

x = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

divisors = make_divisors(x)

for divisor in divisors:
  for a in range(1000):
    b = a - divisor
    if (a**5 - b**5 == x):
      print(a, b)
      break
### BUGGY CODE ###

N,K=map(int,input().split())
P=list(map(int,input().split()))
kouho=[]
def saikorokitaiti(A):
    return ((P[A]*(1+P[A])/2)/P[A])
kari=[]
hako=[]
if K==1:
    print(saikorokitaiti(P.index(max(P))))
    exit()
for i in range(K):
    hako.append(saikorokitaiti(i))
for j in range(N-K+1):
    if j==0:
        kouho.append(sum(hako))
    elif j+K-1<N:
        hako.append(saikorokitaiti(j+K-1))
        hako.pop(0)
        kouho.append(sum(hako))
#print(kouho)
print(max(kouho))

### FIXED CODE ###

import sys
input = sys.stdin.readline
N,K=map(int,input().split())
P=list(map(int,input().split()))
kouho=0
def saikorokitaiti(A):
    return ((P[A]*(1+P[A])/2)/P[A])
kari=[]
hako=[]
kitaiti=0
if K==1:
    print(saikorokitaiti(P.index(max(P))))
    exit()
for i in range(K):
    hako.append(saikorokitaiti(i))
    kitaiti+=saikorokitaiti(i)
    kouho=kitaiti
b=0
for j in range(N-K+1):
    if j==0:
        continue
    elif j+K-1<N:
        hako.append(saikorokitaiti(j+K-1))
        kitaiti+=saikorokitaiti(j+K-1)
        kitaiti-=hako[b]
        b+=1
        kouho=max(kouho,kitaiti)
#print(kouho)
print(kouho)
### BUGGY CODE ###

from itertools import chain
import copy

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

lis = [[10000000 for i in range(n)] for j in range(n)]
hen = []
for _ in range(m):
    hen.append(list(map(int, input().split())))

ans = 0
for x in range(m):
    lis_tmp = copy.deepcopy(lis)
    bri = copy.deepcopy(hen)
    bri.pop(x)
    for y in range(m-1):
        lis_tmp[bri[y][0]-1][bri[y][1]-1] = 1
        lis_tmp[bri[y][1]-1][bri[y][0]-1] = 1

    for k in range(n):
        for i in range(n):
            for j in range(n):
                lis_tmp[i][j] = min(lis_tmp[i][j], lis_tmp[i][k] + lis_tmp[k][j])

    if 10000000 in list(chain.from_iterable(lis_tmp)):
        ans += 1

print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
hen = []
for _ in range(m):
    hen.append(list(map(int, input().split())))

def dfs(vis, graph, x, n):
    vis[x] = True
    for i in range(n):
        if graph[x][i] == False:
            continue
        if vis[i] == True:
            continue
        dfs(vis, graph, i, n)
    return vis


ans = 0
for i in range(m):
    graph = [[False for _ in range(n)] for _ in range(n)]
    rng = [a for a in range(m)]
    del rng[i]
    for y in rng:
        graph[hen[y][0]-1][hen[y][1]-1] = True
        graph[hen[y][1]-1][hen[y][0]-1] = True
    vis = [False for _ in range(n)]
    vis = dfs(vis, graph, 0, n)
    connected = True
    for k in range(n):
        if vis[k] == False:
            connected = False
    if connected == False:
        ans += 1

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

import sys
sys.setrecursionlimit(10**7)
N,K=map(int,input().split())
A=[int(i) for i in input().split()]
dp=[-1]*(K+1)#0=False 1=True
def sea(i):
    if dp[i]!=-1:
        return dp[i]
    s=1
    flag=0
    for a in A:
        if i-a>=0:
            flag=1
            s*=sea(i-a)
    if flag==0:
        dp[i]=0
        return 0
    dp[i]=1-s
    return 1-s
if sea(K)==0:
    print('Second')
else:
    print('First')

### FIXED CODE ###

N,K=map(int,input().split())
A=[int(i) for i in input().split()]
dp=[0]*(K+1)
dp[0]=0
for i in range(1,K+1):
    flag=0
    s=1
    for a in A:
        if i-a>=0:
            s*=dp[i-a]
            flag=1
    if flag==0:
        dp[i]=0
    else:
        dp[i]=1-s
#print(dp)
if dp[K]==0:
    print('Second')
else:
    print('First')
### BUGGY CODE ###

N , K = map(int, input().split())
A = list(map(int, input().split()))
syurui = set(A)
n_syurui =len(syurui)
ans = 0
goukei = sorted([A.count(i) for i in syurui])

if n_syurui > K:
    ans = sum(goukei[:n_syurui-K])
    print(ans)
else:
    print(ans)

### FIXED CODE ###

import collections
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
hint = collections.Counter(A)
ans = 0
bb = hint.most_common()
if K >= len(bb):
    print(ans)
else:
    for i in range(-1, -(len(bb)-K)-1, -1):
        ans += bb[i][1]
    print(ans)