#include <bits/stdc++.h>
using namespace std;
int N, k, there[(int)1e5 + 3], ans, take = 1e9;
int main() {
  ios::sync_with_stdio(false);
  cin >> N >> k;
  for (int i = 0; i < N; i++) {
    char x;
    cin >> x;
    there[x - 'A']++;
  }
  for (int i = 0; i < k; i++) take = min(take, there[i]);
  cout << take * k;
  return 0;
}
