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

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



K = len(list(set(a)))



if K <= k:

    print((0))

else:

    rewrite = K - k

    ans = 0

    cnt = [0] *(max(a) + 1)



    for i in range(n):

        cnt[a[i]] += 1

    cnt.sort()

    # print(cnt)

    for c in cnt:

        if 0 < c:

            ans += c

            rewrite -= 1

            if rewrite == 0:

                print(ans)

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

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



if len(list(set(a))) <= k:

    print((0))

else:

    ans = 0

    cnt = [0] *(max(a) + 1)



    for i in range(n):

        cnt[a[i]] += 1

    cnt.sort(reverse=True)

    tmp = 0

    for c in cnt:

        ans += c

        tmp += 1

        if k == tmp:

            ans = n - ans

            print(ans)

            exit()

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
K = len(list(set(a)))
if K <= k:
    print((0))
else:
    rewrite = K - k
    ans = 0
    cnt = [0] * (max(a) + 1)
    for i in range(n):
        cnt[a[i]] += 1
    cnt.sort()
    # print(cnt)
    for c in cnt:
        if 0 < c:
            ans += c
            rewrite -= 1
            if rewrite == 0:
                print(ans)
                exit()

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
if len(list(set(a))) <= k:
    print((0))
else:
    ans = 0
    cnt = [0] * (max(a) + 1)
    for i in range(n):
        cnt[a[i]] += 1
    cnt.sort(reverse=True)
    tmp = 0
    for c in cnt:
        ans += c
        tmp += 1
        if k == tmp:
            ans = n - ans
            print(ans)
            exit()

-K = len(list(set(a))) -if K <= k: +if len(list(set(a))) <= k: -    rewrite = K - k -    cnt.sort() -    # print(cnt) +    cnt.sort(reverse=True) +    tmp = 0 -        if 0 < c: -            ans += c -            rewrite -= 1 -            if rewrite == 0: -                print(ans) -                exit() +        ans += c +        tmp += 1 +        if k == tmp: +            ans = n - ans +            print(ans) +            exit()