#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int num = 0, neg = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') neg = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    num = (num << 3) + (num << 1) + c - '0';
    c = getchar();
  }
  return num * neg;
}
long long n, k;
int last[110][30], used[30];
char str[110];
long long f[110][110], res, ans;
int main() {
  n = read(), k = read();
  scanf("%s", str + 1);
  str[n + 1] = 'a';
  for (int i = 1; i <= n + 1; i++) {
    for (int j = 1; j <= 26; j++) last[i][j] = used[j];
    used[str[i] - 'a' + 1] = i;
  }
  for (int i = 1; i <= n; i++) {
    f[i][1] = 1;
    for (int j = 1; j <= 26; j++)
      for (int len = 2; len <= n; len++) f[i][len] += f[last[i][j]][len - 1];
  }
  for (int len = n; len >= 1; len--)
    for (int i = 1; i <= 26; i++) {
      int j = last[n + 1][i];
      res += f[j][len];
      ans += f[j][len] * (n - len);
      if (res >= k) {
        ans -= (n - len) * (res - k);
        cout << ans;
        return 0;
      }
    }
  if (res == k - 1)
    cout << ans + n;
  else
    printf("-1");
  return 0;
}
