#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int maxn = 105;
int pos[maxn][26];
LL dp[maxn][maxn];
char s[maxn];
int main() {
  int n;
  LL k;
  scanf("%d%lld", &n, &k);
  scanf("%s", s + 1);
  int i, j;
  for (i = 1; i <= n; i++) {
    for (j = 0; j < 26; j++) {
      if (s[i] - 'a' == j) {
        pos[i][j] = i;
      } else
        pos[i][j] = pos[i - 1][j];
    }
  }
  for (i = 1; i <= n; i++) dp[i][1] = 1;
  int len;
  for (len = 2; len <= n; len++) {
    for (i = len; i <= n; i++) {
      for (j = 0; j < 26; j++) {
        dp[i][len] += dp[pos[i - 1][j]][len - 1];
      }
    }
  }
  LL sum = 0;
  LL ans = 0;
  LL temp;
  for (i = n; i >= 1; i--) {
    temp = 0;
    for (j = 0; j < 26; j++) {
      temp += dp[pos[n][j]][i];
    }
    if (sum + temp >= k) {
      ans += (k - sum) * (n - i);
      printf("%lld\n", ans);
      exit(0);
    } else {
      ans += temp * (n - i);
      sum += temp;
    }
  }
  if (sum == k - 1) {
    ans += n;
    printf("%lld\n", ans);
    exit(0);
  }
  printf("-1\n");
  return 0;
}
