#include <bits/stdc++.h>
using namespace std;
long long get_num(string s) {
  long long val = 0;
  for (char ch : s) val = val * 10 + ch - '0';
  return val;
}
long long pow(long long a, long long p, long long m = 1000000007) {
  long long res = 1;
  while (p > 0) {
    if (p & 1) res = (res * a) % m;
    a = (a * a) % m;
    p >>= 1;
  }
  return res;
}
int delta[4][2] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
const long long MAX_CHAR = 256;
void countSub(string str, long long k) {
  vector<long long> last(MAX_CHAR, -1);
  long long n = str.length();
  unordered_map<long long, map<long long, long long>> mm;
  mm[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    mm[i] = mm[i - 1];
    for (auto& it : (mm[i - 1])) {
      mm[i][it.first + 1] += it.second;
    }
    if (last[str[i - 1]] != -1)
      for (auto& it : (mm[last[str[i - 1]]])) mm[i][it.first + 1] -= it.second;
    last[str[i - 1]] = (i - 1);
  }
  auto it = mm[n].rbegin();
  long long cnt = 0;
  while (it != mm[n].rend()) {
    long long temp = min(it->second, k);
    k -= temp;
    cnt += (n - it->first) * temp;
    if (k == 0) break;
    it++;
  }
  if (k)
    cout << -1;
  else
    cout << cnt;
}
void func() {
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  countSub(s, k);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  func();
  return 0;
}
