#include <bits/stdc++.h>
const int mod = 1e9 + 7;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const long long INF = 1e18;
using namespace std;
signed main() {
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<long long> prev(26, -1);
  vector<vector<long long>> dp(n + 1, vector<long long>(n + 1)),
      pref(n + 1, vector<long long>(n + 1));
  dp[0][0] = 1;
  pref[0][0] = 1;
  cerr << "OK" << endl;
  for (long long i = 1; i <= n; ++i) {
    for (long long z = 0; z <= n; ++z) pref[i][z] = pref[i - 1][z];
    for (long long j = 1; j <= n; ++j) {
      if (prev[s[i - 1] - 'a'] == -1) {
        dp[i][j] = pref[i - 1][j - 1];
      } else {
        dp[i][j] = pref[i - 1][j - 1] - pref[prev[s[i - 1] - 'a'] - 1][j - 1];
      }
      pref[i][j] += dp[i][j];
    }
    prev[s[i - 1] - 'a'] = i;
  }
  long long ans = 0;
  for (long long z = n; z >= 0; --z) {
    if (pref[n][z] >= k) {
      ans += k * (n - z);
      k = 0;
      break;
    } else {
      ans += pref[n][z] * (n - z);
      k -= pref[n][z];
    }
  }
  if (k)
    cout << -1;
  else
    cout << ans;
  return 0;
}
