#include <bits/stdc++.h>
using namespace std;
int n, k;
map<string, long long int> card;
string q;
string j;
long long int mayor, mayorant, falta, ans;
int m() {
  for (map<string, long long int>::iterator it = card.begin(); it != card.end();
       ++it) {
    mayor = max(mayor, it->second);
  }
  for (map<string, long long int>::iterator it = card.begin(); it != card.end();
       ++it) {
    if (it->second == mayor) {
      card[it->first] = 0;
      break;
    }
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  while (cin >> n >> k >> q) {
    falta = 0;
    ans = 0;
    card.clear();
    mayor = 0;
    mayorant = 0;
    for (long long int i = 0; i < q.size(); ++i) {
      j = q[i];
      if (card.count(j)) {
        card[j] += 1;
      } else {
        card[j] = 1;
      }
    }
    while (k != 0) {
      m();
      if (k < mayor) {
        falta = mayor - k;
        mayor -= falta;
        ans += mayor * mayor;
        k = 0;
      }
      if (k == mayor) {
        ans += mayor * mayor;
        k = 0;
      }
      if (k > mayor) {
        ans += mayor * mayor;
        falta = k - mayor;
        k -= mayor;
        mayor = 0;
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
