#include <bits/stdc++.h>
using namespace std;
map<char, int> arr;
map<char, int>::iterator it;
int main() {
  int n, k;
  long int min = 100000;
  cin >> n >> k;
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    arr[s[i]]++;
  }
  for (it = arr.begin(); it != arr.end(); it++) {
    if (it->second < min) {
      min = it->second;
    }
  }
  if (arr.size() != k) {
    cout << 0;
  } else {
    cout << min * k;
  }
}
