#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  map<char, int> cnt;
  for (char c : s) {
    cnt[c] += 1;
  }
  int res = n;
  for (char c = 'A'; c < 'A' + k; ++c) {
    res = min(res, cnt[c]);
  }
  cout << res * k << endl;
  return 0;
}
