#include <bits/stdc++.h>
using namespace std;
int main() {
  long long A, T, C, sum = 0;
  cin >> A >> T;
  long long a[26] = {0};
  while (A--) {
    char c;
    cin >> c;
    a[c - 'A']++;
  }
  C = T;
  sort(a, a + 26);
  for (long long i = 25; i >= 0; i--) {
    if (C > 0) {
      if (a[i] >= C) {
        sum = C * C + sum;
        break;
      } else if (a[i] < C) {
        sum = a[i] * a[i] + sum;
        C = C - a[i];
      }
    } else
      break;
  }
  cout << sum << endl;
  return 0;
}
