# region template import typing import math import sys import copy import itertools import collections import bisect import heapq import decimal def ni(): return int(sys.stdin.readline()) def ns(): return map(int, sys.stdin.readline().split()) def ns1(): return map(lambda x: int(x)-1, sys.stdin.readline().split()) def na(): return list(map(int, sys.stdin.readline().split())) def na1(): return list(map(lambda x: int(x)-1, sys.stdin.readline().split())) def nall_i(): return list(map(int, sys.stdin.read().split())) def nall_s(): return list(map(str, sys.stdin.read().split())) def flush(): return sys.stdout.flush() def nib(): return int(sys.stdin.buffer.readline()) def nsb(): return map(int, sys.stdin.buffer.readline().split()) def ns1b(): return map(lambda x: int(x)-1, sys.stdin.buffer.readline().split()) def nab(): return list(map(int, sys.stdin.buffer.readline().split())) def na1b(): return list(map(lambda x: int(x)-1, sys.stdin.buffer.readline().split())) def nallb(): return list(map(int, sys.stdin.buffer.read().split())) # endregion # sys.setrecursionlimit(10**7+1) inf = 10**23 # MOD = 10**9+7 MOD = 998244353 def main(): N, K = ns() A = na() cnt = collections.Counter(A) rem = K res = 0 for k,v in sorted(cnt.items(), key=lambda x: x[1], reverse=True): if rem > 0: rem -= v res += 1 print(res) if __name__ == '__main__': main()