#include <bits/stdc++.h>
using namespace std;
const int Max = 9092;
const int def = 0x3f3f3f3f;
long long dp[200][200];
char a[200];
int main() {
  int i, j, h;
  int n, m;
  long long k;
  scanf("%d %lld", &n, &k);
  scanf("%s", a + 1);
  for (i = 0; i <= n; i++) dp[i][0] = 1;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= i; j++) {
      dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
      for (h = i - 1; h >= 1; h--) {
        if (a[h] == a[i]) {
          dp[i][j] -= dp[h - 1][j - 1];
          break;
        }
      }
    }
  }
  long long sum = 0;
  int base = n;
  while (k >= dp[n][base] && base >= 0) {
    k -= dp[n][base];
    sum += dp[n][base] * (n - base);
    base--;
  }
  if (k && base >= 0) {
    sum += k * (n - base);
  } else if (k && base == -1) {
    printf("-1\n");
    return 0;
  }
  printf("%lld\n", sum);
}
