#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
const int INF = 0x3f3f3f3f;
long long dp[1005][1005];
char a[maxn];
int pre[1005];
int main() {
  int n;
  long long k;
  scanf("%d%I64d%s", &n, &k, a + 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[a[i] - 'a']) dp[i][j] -= dp[pre[a[i] - 'a'] - 1][j - 1];
    }
    pre[a[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)
    printf("-1\n");
  else
    printf("%I64d\n", ans);
  return 0;
}
