#include <bits/stdc++.h>
using namespace std;
template <class T>
void mxi(T& a, const T& b) {
  a = max(a, b);
}
template <class T>
void mni(T& a, const T& b) {
  a = min(a, b);
}
long double EPS = 1e-9;
long long dp[102][102];
string s;
void solve() {
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  map<char, long long> mp;
  for (long long i = 0; i < n; i++) {
    dp[1][i] = 1 - mp[s[i]];
    mp[s[i]] = 1;
    if (i) dp[1][i] += dp[1][i - 1];
  }
  for (long long i = 2; i <= n; i++) {
    mp.clear();
    for (long long j = 1; j < n; j++) {
      dp[i][j] = dp[i][j - 1] + dp[i - 1][j - 1] - mp[s[j]];
      mp[s[j]] = dp[i - 1][j - 1];
    }
  }
  long long ans = 0;
  for (long long i = n; i >= 1; i--) {
    if (k < dp[i][n - 1]) {
      ans += k * (n - i);
      k = 0;
      break;
    } else {
      ans += dp[i][n - 1] * (n - i);
      k -= dp[i][n - 1];
    }
    if (k <= 0) break;
  }
  if (k > 0) {
    k--;
    ans += n;
  }
  if (k > 0) {
    cout << -1 << '\n';
    return;
  }
  cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t, tab;
  t = 1;
  tab = t;
  while (t--) {
    solve();
  }
}
