#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2e5 + 5;
const int INF = 0x3f3f3f3f;
long long dp[105][105];
int pre[30];
char s[MAX_N];
long long n, k;
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++) {
      dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
      if (pre[s[i] - 'a']) dp[i][j] -= dp[pre[s[i] - 'a'] - 1][j - 1];
      dp[i][j] = min(dp[i][j], k);
    }
    pre[s[i] - 'a'] = i;
  }
  long long ans = 0;
  for (int i = n; i >= 0; i--) {
    ans += min(dp[n][i], k) * (n - i);
    k -= dp[n][i];
    if (k <= 0) break;
  }
  if (k > 0)
    puts("-1");
  else
    printf("%lld\n", ans);
  return 0;
}
