#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e12;
int main() {
  long long n, k;
  string s;
  cin >> n >> k >> s;
  vector<vector<int>> nxt(n + 1, vector<int>(26));
  for (int c = 0; c < 26; c++) nxt[n][c] = n;
  for (int i = n - 1; i >= 0; i--) {
    for (int c = 0; c < 26; c++) nxt[i][c] = nxt[i + 1][c];
    nxt[i][s[i] - 'a'] = i;
  }
  vector<vector<long long>> dp(n + 2, vector<long long>(n + 1));
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int len = 0; len < n; len++) {
      for (int c = 0; c < 26; c++) {
        dp[nxt[i][c] + 1][len + 1] += dp[i][len];
        dp[nxt[i][c] + 1][len + 1] = min(dp[nxt[i][c] + 1][len + 1], INF);
      }
    }
  }
  vector<long long> sum(n + 1);
  for (int i = 0; i <= n; i++) {
    for (int len = 0; len <= n; len++) {
      sum[len] += dp[i][len];
      sum[len] = min(sum[len], INF);
    }
  }
  long long ans = 0;
  for (int len = n; len >= 0; len--) {
    long long take = min(k, sum[len]);
    ans += take * (n - len);
    k -= take;
  }
  if (k > 0) ans = -1;
  cout << ans << '\n';
  return 0;
}
