#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x, maxb = 1;
  long long ans = 0;
  map<int, int> m1;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    m1[x]++;
  }
  for (auto c : m1) {
    if (c.second > m) {
      maxb = max(maxb, (c.second / m) + (c.second % m > 0));
    }
  }
  for (auto c : m1) {
    ans += (m * maxb - c.second);
  }
  cout << ans;
  return 0;
}
