#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<vector<long long>> dp(n + 1, vector<long long>(n + 1, 1ll));
  vector<int> pre(26, 0);
  for (int i = 1; i <= s.size(); i++) {
    for (int j = 1; j < i; j++) {
      dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1];
      if (pre[s[i - 1] - 'a'] > 0 && j >= i - pre[s[i - 1] - 'a'])
        dp[i][j] -= dp[pre[s[i - 1] - 'a'] - 1][j - i + pre[s[i - 1] - 'a']];
    }
    pre[s[i - 1] - 'a'] = i;
  }
  long long ans = 0;
  for (int i = 0; i <= n; i++) {
    if (k >= dp[n][i]) {
      ans += dp[n][i] * i;
      k -= dp[n][i];
    } else {
      ans += k * i;
      k = 0;
      break;
    }
  }
  if (k > 0) {
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}
