#include <bits/stdc++.h>
using namespace std;
long long poww(long long a, long long b, long long md) {
  return (!b ? 1
             : (b & 1 ? a * poww(a * a % md, b / 2, md) % md
                      : poww(a * a % md, b / 2, md) % md));
}
const long long MAXN = 2e2 + 10;
const long long INF = 8e18;
const long long MOD = 1e9 + 7;
long long dp[MAXN][MAXN] = {0}, F[MAXN][26], tmp[26] = {0}, n, k;
long long cst[MAXN] = {0};
void overflow_ctrl(long long& a) { a = min(a, k); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> n >> k >> s;
  s = 'N' + s + 'N';
  for (int i = 1; i <= n + 1; i++) {
    for (int j = 0; j < 26; j++) F[i][j] = tmp[j];
    tmp[s[i] - 'a'] = i;
  }
  dp[1][0] = dp[1][1] = 1;
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (j == 1) {
        dp[i][j] = 1;
        continue;
      }
      for (int c = 0; c < 26; c++) {
        overflow_ctrl(dp[i][j] += dp[F[i][c]][j - 1]);
      }
    }
  }
  for (int i = n; i >= 1; i--) {
    for (int c = 0; c < 26; c++) {
      overflow_ctrl(cst[n - i] += dp[F[n + 1][c]][i]);
    }
  }
  cst[n]++;
  long long ans = 0;
  for (int i = 0; i <= n; i++) {
    long long x = min(k, cst[i]);
    k -= x;
    ans += i * x;
  }
  if (k > 0) return cout << -1 << '\n', 0;
  cout << ans << '\n';
  return 0;
}
