#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000007;
const int MOD = 1000000007;
const int nmax = 201234;
int n;
long long k, res, cnt[102], dp[102][26];
char s[102];
int main() {
  scanf("%d%I64d", &n, &k);
  scanf("%s", s + 1);
  cnt[0] = 1;
  for (int tmp, i = 1; i <= n; ++i) {
    tmp = s[i] - 'a';
    for (int j = 1; j <= i; ++j) dp[j][tmp] = cnt[j - 1];
    for (int j = 1; j <= i; ++j) {
      cnt[j] = 0;
      for (int k = 0; k < 26; ++k) {
        cnt[j] += dp[j][k];
      }
      if (cnt[j] >= k) cnt[j] = k;
    }
  }
  for (int tmp = 0, i = n; i >= 0; --i, ++tmp) {
    if (k <= cnt[i]) {
      res += (long long)tmp * k;
      k = 0;
      break;
    } else {
      res += (long long)tmp * cnt[i];
      k -= cnt[i];
    }
  }
  if (k == 0)
    printf("%I64d\n", res);
  else
    printf("-1\n");
  return 0;
}
