import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random #sys.setrecursionlimit(10**9) #n = int(input()) n,k = map(int,input().split()) alist = list(map(int,input().split())) #hen = collections.defaultdict(list) #s = input() # #for i in range(n): # alist.append(list(map(int,input().split()))) # u,v = map(int,input().split()) # hen[u].append(v) # hen[v].append(u) #dp = [[0]*n for i in range(m)] c = collections.Counter(alist) h = [] for i in set(alist): heapq.heappush(h,-c[i]) ans = 0 temp = 0 while temp < k: ans += 1 temp -= heapq.heappop(h) print(ans)