#include <bits/stdc++.h>
using namespace std;
long long dp[105][105];
long long lst[105];
long long n, k;
char str[105];
signed main() {
  scanf("%I64d%I64d", &n, &k);
  getchar();
  for (long long i = 1; i <= n; i++) scanf("%c", &str[i]);
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j < i; j++) {
      if (str[i] == str[j]) lst[i] = j;
    }
  }
  for (long long i = 0; i <= n; i++) dp[i][0] = 1;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= i; j++) {
      if (lst[i] == 0) {
        dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
      } else
        dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j] - dp[lst[i] - 1][j - 1];
    }
  }
  long long ans = 0;
  long long judge = 0;
  for (long long i = 0; i <= n; i++) {
    ans += dp[n][i];
    if (ans >= k) {
      judge = 1;
      break;
    }
  }
  if (judge == 0)
    printf("-1\n");
  else {
    long long ans1 = 0, cnt = 0;
    for (long long i = n; i >= 0; i--) {
      if (cnt + dp[n][i] <= k) {
        cnt += dp[n][i];
        ans1 += (dp[n][i] * (n - i));
      } else {
        long long f = (k - cnt);
        ans1 += (f * (n - i));
        break;
      }
    }
    printf("%I64d\n", ans1);
  }
  return 0;
}
