//Object.entries()
function entries(obj) {
    array = [];
    for (var i of Object.keys(obj)) {
        tmp = new Array(i, obj[i]);
        array.push(tmp);
    }
    return array;
}
function Main(input) {
    input = input.split("\n");
    input[0] = input[0].split(" ").map(Number);
    N = input[0][0];
    K = input[0][1];
    A = input[1].split(" ").map(Number);
    obj = {};
    for (i of A) {
        if (!obj[i]) obj[i] = 1;
        else obj[i]++;
    }
    array = entries(obj).sort((a, b) => a[1] - b[1]);
    ans = 0;
    if (array.length > K) for (i = 0; i < array.length - K; i++) ans += array[i][1];
    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));