#include <bits/stdc++.h>
using namespace std;
int mini(int arr[]) {
  int min = 100000;
  for (int i = 0; i < 26; i++) {
    if (arr[i] < min && arr[i] > 0) min = arr[i];
  }
  return min;
}
int main() {
  int n, k;
  cin >> n >> k;
  char ch[n];
  cin >> ch;
  int val = 0;
  static int arr[26];
  for (int i = 0; i < n; i++) {
    arr[ch[i] - 65]++;
  }
  for (int i = 0; i < 26; i++) {
    if (arr[i] > 0) val++;
  }
  if (val == k) {
    cout << k * mini(arr) << endl;
  } else {
    cout << "0\n";
  }
  return 0;
}
