#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<long long> cnt(101);
  for (long long i = 0; i < n; i++) {
    cnt[a[i]]++;
  }
  long long ans = 1e9;
  for (long long m = *max_element(cnt.begin(), cnt.end()); m < 10000; m++) {
    long long ans1 = 0;
    if (m % k == 0) {
      for (long long i = 0; i < 101; i++) {
        if (cnt[i] != 0) {
          ans1 += (m - cnt[i]);
        }
      }
      if (ans1 < 0) {
        continue;
      } else {
        ans = min(ans, ans1);
        break;
      }
    }
  }
  cout << ans;
}
