#include <bits/stdc++.h>
using namespace std;
int a[26], b[26];
int main() {
  int n, k, i, c = 0;
  string s;
  cin >> n >> k;
  cin >> s;
  for (i = 0; i < n; i++) {
    a[s[i] - 'A']++;
  }
  int min = a[0], t = 0;
  for (i = 0; i < k; i++) {
    if (a[i] == 0) {
      t = 1;
    }
    if (a[i] < min) min = a[i];
  }
  for (i = 0; i < n; i++) {
    if ((s[i] - 'A') < k) {
      if (b[s[i] - 'A'] < min) {
        b[s[i] - 'A']++;
        c++;
      }
    }
  }
  cout << c;
  return 0;
}
