#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1, ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long n, k;
char a[105];
long long dp[105][105];
long long place[200005];
long long last[200005];
long long ans = 0;
signed main() {
  n = read(), k = read();
  scanf("%s", a + 1);
  for (long long i = 1; i <= n; i++) {
    if (place[a[i] - 'a' + 1]) {
      last[i] = place[a[i] - 'a' + 1];
      place[a[i] - 'a' + 1] = i;
    } else
      place[a[i] - 'a' + 1] = i;
  }
  dp[n][0] = 1;
  for (long long i = 1; i <= n; i++) {
    if (last[i])
      dp[i][1] = dp[i - 1][1];
    else
      dp[i][1] = dp[i - 1][1] + 1;
  }
  for (long long len = 2; len <= n; len++) {
    for (long long i = len; i <= n; i++) {
      dp[i][len] = dp[i - 1][len - 1] + dp[i - 1][len];
      if (last[i]) {
        dp[i][len] -= dp[last[i] - 1][len - 1];
      }
    }
  }
  long long now = 0;
  for (long long i = n; i >= 0; i--) {
    long long money = n - i;
    if (dp[n][i] <= k) {
      k -= dp[n][i];
      ans += money * dp[n][i];
    } else {
      ans += money * k;
      k = 0;
    }
    if (k <= 0) break;
  }
  if (k > 0)
    printf("-1\n");
  else
    printf("%lld\n", ans);
  return 0;
}
