#include <bits/stdc++.h>
int main() {
  int a[27] = {0};
  int n, m, min = 0x7fffffff;
  char ch;
  scanf("%d %d", &n, &m);
  getchar();
  while ((ch = getchar()) != '\n') {
    a[ch - 65]++;
  }
  for (int i = 0; i < m; i++) {
    if (min > a[i]) min = a[i];
  }
  printf("%d", min * m);
  return 0;
}
