#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  unordered_map<char, long long> freq;
  for (long long i = 0; i < n; i++) {
    freq[s[i]]++;
  }
  long long min_freq = 1e9;
  for (auto itr = freq.begin(); itr != freq.end(); itr++) {
    min_freq = min((itr->second), min_freq);
  }
  long long answer = 0;
  if (freq.size() == k) {
    answer = min_freq * freq.size();
  }
  cout << answer << "\n";
  return 0;
}
