#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
const long long inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
long long n, k;
long long dp[maxn][maxn];
char s[maxn];
int las[maxn];
int main() {
  scanf("%lld%lld", &n, &k);
  scanf("%s", s + 1);
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    dp[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      if (las[s[i] - 'a']) {
        dp[i][j] =
            (dp[i - 1][j] + dp[i - 1][j - 1] - dp[las[s[i] - 'a'] - 1][j - 1]);
      } else {
        dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - 1]);
      }
    }
    las[s[i] - 'a'] = i;
  }
  long long ans = 0;
  for (int i = n; i >= 0; i--) {
    if (k <= dp[n][i]) {
      ans += k * (n - i);
      k = 0;
      break;
    }
    k -= dp[n][i];
    ans += dp[n][i] * (n - i);
  }
  if (!k)
    printf("%lld\n", ans);
  else
    printf("-1");
  return 0;
}
