import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, core.bitop;

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];
    auto AS = new int[](N+1);
    foreach (a; readln.split.to!(int[])) ++AS[a];
    sort!"a > b"(AS);
    int[] bs;
    foreach (a; AS) {
        if (a == 0) break;
        bs ~= a;
    }
    sort!"a < b"(bs);
    auto d = max(0, bs.length.to!int - K);
    int r;
    foreach (i; 0..d) r += bs[i];
    writeln(r);
}