# -*- coding: utf-8 -*-



# AtCoder Beginner Contest

# Problem C



if __name__ == '__main__':

    from collections import Counter



    ball_count, kind_count = list(map(int, input().split()))

    ball_numbers = Counter(list(map(int, input().split())))

    sorted_ball_numbers = sorted(list(ball_numbers.items()), key=lambda x: x[1])

    ball_number_key_count = len(list(ball_numbers.keys()))



    need_rewritten_count = 0

    diff_count = ball_number_key_count - kind_count



    if diff_count > 0:

        for i, (key, value) in enumerate(sorted_ball_numbers):

            if diff_count > i:

                need_rewritten_count += value



    print(need_rewritten_count)

# -*- coding: utf-8 -*-



# AtCoder Beginner Contest

# Problem C



if __name__ == '__main__':

    from collections import Counter



    ball_count, kind_count = list(map(int, input().split()))

    ball_numbers = Counter(list(map(int, input().split())))

    sorted_ball_numbers = sorted(ball_numbers.values())

    print((sum(sorted_ball_numbers[:-kind_count])))

# -*- coding: utf-8 -*-
# AtCoder Beginner Contest
# Problem C
if __name__ == "__main__":
    from collections import Counter

    ball_count, kind_count = list(map(int, input().split()))
    ball_numbers = Counter(list(map(int, input().split())))
    sorted_ball_numbers = sorted(list(ball_numbers.items()), key=lambda x: x[1])
    ball_number_key_count = len(list(ball_numbers.keys()))
    need_rewritten_count = 0
    diff_count = ball_number_key_count - kind_count
    if diff_count > 0:
        for i, (key, value) in enumerate(sorted_ball_numbers):
            if diff_count > i:
                need_rewritten_count += value
    print(need_rewritten_count)

# -*- coding: utf-8 -*-
# AtCoder Beginner Contest
# Problem C
if __name__ == "__main__":
    from collections import Counter

    ball_count, kind_count = list(map(int, input().split()))
    ball_numbers = Counter(list(map(int, input().split())))
    sorted_ball_numbers = sorted(ball_numbers.values())
    print((sum(sorted_ball_numbers[:-kind_count])))

-    sorted_ball_numbers = sorted(list(ball_numbers.items()), key=lambda x: x[1]) -    ball_number_key_count = len(list(ball_numbers.keys())) -    need_rewritten_count = 0 -    diff_count = ball_number_key_count - kind_count -    if diff_count > 0: -        for i, (key, value) in enumerate(sorted_ball_numbers): -            if diff_count > i: -                need_rewritten_count += value -    print(need_rewritten_count) +    sorted_ball_numbers = sorted(ball_numbers.values()) +    print((sum(sorted_ball_numbers[:-kind_count])))