#include <bits/stdc++.h>
long long int a[26] = {0};
int main() {
  long long int n, k, result;
  char s[100005];
  scanf("%lld %lld", &n, &k);
  scanf("%s", s);
  for (int i = 0; s[i] != '\0'; i++) {
    a[s[i] - 65]++;
  }
  for (int i = 0; i < 26; i++) {
    for (int j = i; j < 26; j++) {
      if (a[i] < a[j]) {
        long long int temp = a[i];
        a[i] = a[j];
        a[j] = temp;
      }
    }
  }
  for (int i = 0; i < 26; i++) {
    long long int temp = (a[i] < k) ? a[i] : k;
    result += temp * temp;
    k -= temp;
    if (k == 0) break;
  }
  printf("%lld", result);
  return 0;
}
