#include <bits/stdc++.h>
using namespace std;
long long dp[150][150] = {0}, ans[150] = {0}, sum = 0;
bool vis[200] = {0};
char a[150];
long long n, k;
int main() {
  cin >> n >> k;
  cin >> a;
  for (int i = 0; i < n; i++) {
    if (!vis[a[i]]) ans[1]++;
    vis[a[i]] = 1;
  }
  for (int i = n - 1; i >= 0; i--) {
    dp[i][1] = 1;
    for (int j = 97; j <= 122; j++) {
      int temp;
      for (temp = i + 1; temp < n; temp++) {
        if (a[temp] == j) break;
      }
      if (temp != n) {
        for (int l = 2; l <= n; l++) dp[i][l] += dp[temp][l - 1];
      }
    }
  }
  for (int i = n; i > 1; i--) {
    memset(vis, 0, sizeof(vis));
    for (int j = 0; j < n; j++) {
      if (!vis[a[j]]) ans[i] += dp[j][i];
      vis[a[j]] = 1;
    }
  }
  ans[0] = 1;
  for (int i = n; i >= 0; i--) {
    k -= ans[i];
    sum += ans[i] * (n - i);
    if (k <= 0) {
      sum -= (long long)(-k) * (n - i);
      printf("%lld", sum);
      return 0;
    }
  }
  printf("-1");
  return 0;
}
