#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long int k;
  cin >> n >> k;
  string s;
  cin >> s;
  int nx[26][110];
  for (int i = 0; i < 26; i++) nx[i][n] = n + 1;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < 26; j++) nx[j][i] = nx[j][i + 1];
    nx[s[i] - 'a'][i] = i + 1;
  }
  long long int dp[110][110] = {};
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= i; j++) {
      for (int l = 0; l < 26; l++) {
        if (nx[l][i] > n) continue;
        dp[nx[l][i]][j + 1] += dp[i][j];
        if (dp[nx[l][i]][j + 1] > k) dp[nx[l][i]][j + 1] = k + 1;
      }
    }
  }
  long long int cnt[110] = {};
  cnt[0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      cnt[i] += dp[j][i];
      if (cnt[i] > k) cnt[i] = k + 1;
    }
  }
  long long int ans = 0;
  for (int i = n; i >= 0; i--) {
    ans += min(cnt[i], k) * (n - i);
    k -= min(cnt[i], k);
  }
  if (k > 0)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}
