let K = readLine()!.characters.split(" ").map{Int(String(" "))!}[1]
let A = readLine()!.characters.split(" ").map{Int(String(" "))!}
var arr = (0..<200000).map{_ in 0}
for i in A {
    arr[i-1] += 1
}
arr = arr.filter{$0>0}.sort()
print((0..<max(arr.count-K, 0)).reduce(0){$0+arr[$1]})