#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  unordered_map<char, long long> m;
  for (auto it : s) {
    m[it]++;
  }
  if (m.size() < k) {
    cout << 0;
    return 0;
  }
  long long ans = INT64_MAX;
  for (auto it : m) {
    ans = min(ans, it.second);
  }
  cout << ans * k;
}
