#include <bits/stdc++.h>
using namespace std;
const int maxn = 111;
long double dp[maxn][maxn];
long double psum[maxn][maxn];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  long double k;
  cin >> n >> k;
  if (n <= 60 and k > (1ll << n)) {
    cout << -1 << endl;
    return 0;
  }
  int last[26] = {0};
  int prev[n + 1];
  string s;
  cin >> s;
  for (int i = 0; i < n; i++) {
    prev[i + 1] = last[s[i] - 'a'];
    last[s[i] - 'a'] = i + 1;
  }
  for (int i = 0; i <= n; i++) {
    dp[0][i] = 1;
    psum[0][i] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      dp[j][i] = psum[j - 1][i - 1];
      psum[j][i] = psum[j][i - 1] + dp[j][i] - dp[j][prev[i]];
    }
  }
  long long ans = 0;
  for (int i = n; i >= 0; i--) {
    ans += min(k, psum[i][n]) * (n - i);
    k -= min(k, psum[i][n]);
  }
  if (k)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}
