#include <bits/stdc++.h>
using namespace std;
const int OO = 1e8 + 9, N = 2000 + 9;
const long long mod = 998244353LL;
bool good(vector<int> &v) {
  bool f = true;
  int d = v[1] - v[0];
  for (int i = 1; i < v.size(); i++) f &= (v[i] - v[i - 1] == d);
  return f;
}
bool solve(int d, vector<pair<int, int> > &arr) {
  int n = arr.size();
  vector<int> tmp(n);
  for (int i = 0; i < n; i++) tmp[i] = arr[i].first;
  int ans = 0;
  for (int i = 1; i < n; i++) {
    if (arr[i].first - arr[i - 1].first != d) {
      ans = i;
      break;
    }
  }
  auto tmp2 = tmp;
  tmp2.erase(tmp2.begin() + ans - 1);
  tmp.erase(tmp.begin() + ans);
  if (good(tmp)) {
    printf("%d\n", arr[ans].second);
    return true;
  }
  if (good(tmp2)) {
    printf("%d\n", arr[ans - 1].second);
    return true;
  }
  return false;
}
vector<int> last[103];
long long dp[103][103];
void test() {
  long long n, k;
  string s;
  cin >> n >> k >> s;
  last[0] = vector<int>(26, -1);
  for (int i = 0; i <= n; i++) {
    if (i) {
      last[i] = last[i - 1];
      char ch = s[i - 1];
      last[i][ch - 'a'] = i - 1;
    }
  }
  for (int i = 0; i < n; i++) dp[1][i] = 1;
  for (int len = 2; len <= n; len++) {
    for (int i = len - 1; i < n; i++) {
      for (int j = 0; j < 26; j++) {
        if (~last[i][j]) {
          dp[len][i] += dp[len - 1][last[i][j]];
          dp[len][i] = min(dp[len][i], k);
        }
      }
    }
  }
  long long ans = 0;
  for (int len = n; len >= 1; len--) {
    for (int j = 0; j < 26; j++) {
      if (~last[n][j]) {
        long long mn = min((long long)dp[len][last[n][j]], k);
        ans += (n - len) * mn;
        k -= mn;
      }
    }
  }
  if (k) k--, ans += n;
  if (k)
    printf("-1\n");
  else
    printf("%lld\n", ans);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int t = 1;
  for (int cas = 1; cas <= t; cas++) test();
}
