#include <cstdio>
#include <algorithm>
#include <iostream>
const int N = int(1e5) + 1;
int n, k;
int ai;
int a[N];
int p[N];
long long ans;
bool comp(int x, int y)
{
return a[x] < a[y];
}
int main()
{
freopen("input.txt", "rt", stdin);
freopen("output.txt", "wt", stdout);
scanf("%d%d", &n, &k);
for (int i = 0; i < n; i++)
{
scanf("%d", &ai);
a[ai - 1]++;
}
for (int i = 0; i < k; i++)
p[i] = i;
std::sort(p, p + k, comp);
int sum = n;
for (int i = 0; i < k; i++)
{
ans += sum;
sum -= a[p[i]];
}
std::cout << ans;
return 0;
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGlvc3RyZWFtPgoKY29uc3QgaW50IE4gPSBpbnQoMWU1KSArIDE7CgppbnQgbiwgazsKaW50IGFpOwppbnQgYVtOXTsKaW50IHBbTl07CmxvbmcgbG9uZyBhbnM7Cgpib29sIGNvbXAoaW50IHgsIGludCB5KQp7CglyZXR1cm4gYVt4XSA8IGFbeV07Cn0KCmludCBtYWluKCkKewoJZnJlb3BlbigiaW5wdXQudHh0IiwgInJ0Iiwgc3RkaW4pOwoJZnJlb3Blbigib3V0cHV0LnR4dCIsICJ3dCIsIHN0ZG91dCk7CgoJc2NhbmYoIiVkJWQiLCAmbiwgJmspOwoKCWZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKQoJewoJCXNjYW5mKCIlZCIsICZhaSk7CgoJCWFbYWkgLSAxXSsrOwoJfQoKCWZvciAoaW50IGkgPSAwOyBpIDwgazsgaSsrKQoJCXBbaV0gPSBpOwoKCXN0ZDo6c29ydChwLCBwICsgaywgY29tcCk7CgoJaW50IHN1bSA9IG47CgoJZm9yIChpbnQgaSA9IDA7IGkgPCBrOyBpKyspCgl7CgkJYW5zICs9IHN1bTsKCQlzdW0gLT0gYVtwW2ldXTsKCX0KCglzdGQ6OmNvdXQgPDwgYW5zOwoKCXJldHVybiAwOwp9