#include <bits/stdc++.h>
using namespace std;
const int N = 105;
string s;
int pre[N], last[N], n;
long long dp[N][N], k;
int main() {
  scanf("%d%lld", &n, &k);
  cin >> s;
  s = " " + s;
  for (int i = 1, x; i <= n; i++) {
    x = s[i] - 'a';
    pre[i] = last[x];
    last[x] = i;
  }
  for (int i = 0; i <= n; i++) dp[i][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
      dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1];
      if (pre[i]) dp[i][j] -= dp[pre[i] - 1][j - 1];
    }
  }
  long long ans = 0;
  for (int j = n; j >= 0; j--) {
    if (k >= dp[n][j]) {
      ans += 1ll * (n - j) * dp[n][j];
      k -= dp[n][j];
    } else {
      ans += 1ll * (n - j) * k;
      k = 0;
      break;
    }
  }
  if (k)
    printf("-1\n");
  else
    printf("%lld\n", ans);
  return 0;
}
