#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  unordered_map<char, int> unmap;
  for (char c : s) {
    unmap[c]++;
  }
  if (unmap.size() < k)
    cout << 0 << '\n';
  else {
    int mn = INT_MAX;
    for (auto it : unmap) {
      mn = min(mn, it.second);
    }
    cout << mn * k << '\n';
  }
}
