#include <bits/stdc++.h>
using namespace std;
vector<long long> v, vc;
long long A[100005];
map<long long, long long> mp;
bool cmp(long long a, long long b) { return a > b; }
int main() {
  long long n, i, j, k, l, sum, avg, x, y, z;
  string s, p;
  cin >> n >> k;
  cin >> s;
  sort(s.begin(), s.end());
  if (n == 1 && n < k)
    cout << 0 << endl;
  else {
    for (i = 0; i < n; i++) {
      A[s[i] - 'A']++;
    }
    long long cnt = 0;
    unordered_set<char> u{s.begin(), s.end()};
    long long sz = u.size();
    for (i = 0; i < n; i++) {
      if (A[i] != 0) {
        v.push_back(A[i]);
      }
    }
    sort(v.begin(), v.end(), cmp);
    long long mn = 999999999999;
    for (i = 0; i < k; i++) {
      mn = min(mn, v[i]);
    }
    if (sz < k)
      cout << 0 << endl;
    else
      cout << k * mn << endl;
  }
  return 0;
}
