from collections import Counter

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

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



c = Counter(a)

kv = sorted(list(c.items()), key=lambda x: x[1], reverse=True)



if n <= k:

    print((0))

else:

    ls = c.most_common(k)

    ans = n

    for k, v in ls:

        ans -= v



    print(ans)
from collections import Counter

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

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

c = Counter(a)



if n <= k:

    print((0))

else:

    ls = c.most_common(k)

    ans = n

    for k, v in ls:

        ans -= v



    print(ans)
from collections import Counter

n, k = list(map(int, input().split()))
(*a,) = list(map(int, input().split()))
c = Counter(a)
kv = sorted(list(c.items()), key=lambda x: x[1], reverse=True)
if n <= k:
    print((0))
else:
    ls = c.most_common(k)
    ans = n
    for k, v in ls:
        ans -= v
    print(ans)

from collections import Counter

n, k = list(map(int, input().split()))
(*a,) = list(map(int, input().split()))
c = Counter(a)
if n <= k:
    print((0))
else:
    ls = c.most_common(k)
    ans = n
    for k, v in ls:
        ans -= v
    print(ans)

-kv = sorted(list(c.items()), key=lambda x: x[1], reverse=True)