#include <bits/stdc++.h>
using namespace std;
const long long MAX_N = 100 + 5, MAX_C = 26 + 5;
long long n, k, a[MAX_N], nxt[MAX_C][MAX_N];
long long cnt[MAX_N], dp[MAX_N][MAX_N];
void read_input() {
  string s;
  cin >> n >> k >> s;
  for (long long i = 0; i < n; i++) a[i] = s[i] - 'a';
}
void find_nxt() {
  memset(nxt, 63, sizeof nxt);
  for (long long i = n - 1; ~i; i--)
    for (long long j = 0; j < 26; j++) {
      nxt[j][i] = nxt[j][i + 1];
      if (a[i] == j) nxt[j][i] = i;
    }
}
void dfs(long long i = 0, long long h = 0) {
  cnt[h]++;
  for (long long c = 0; c < 26; c++)
    if (nxt[c][i] < n) dfs(nxt[c][i] + 1, h + 1);
}
void check(long long &x) { x = min(x, (long long)1e16); }
void find_dp() {
  dp[0][0] = 1;
  for (long long i = 0; i <= n; i++)
    for (long long j = 0; j <= n; j++) {
      check(dp[i][j]);
      for (long long c = 0; c < 26; c++)
        if (nxt[c][i] < n) dp[nxt[c][i] + 1][j + 1] += dp[i][j];
    }
}
void fill_cnt() {
  for (long long i = 0; i <= n; i++)
    for (long long j = 0; j <= n; j++) {
      cnt[j] += dp[i][j];
      check(cnt[j]);
    }
}
void solve() {
  find_nxt();
  find_dp();
  fill_cnt();
}
void print_output() {
  long long ans = 0;
  for (long long i = n; ~i; i--) {
    long long w = min(k, cnt[i]);
    ans += w * (n - i);
    k -= w;
  }
  if (k)
    cout << -1;
  else
    cout << ans;
}
int32_t main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  read_input();
  solve();
  print_output();
}
