#include <bits/stdc++.h>
using namespace std;
long long want, ans, now, n, dp[105][105];
string s;
bool vis[105];
inline long long read() {
  long long ans = 0;
  int f = 1;
  char in = getchar();
  while (!(in >= '0' & in <= '9')) {
    if (in == '-') {
      f = -f;
    }
    in = getchar();
  }
  while (in >= '0' && in <= '9') {
    ans = (ans << 1) + (ans << 3) + (in ^ '0');
    in = getchar();
  }
  return ans * f;
}
int main() {
  n = read();
  want = read();
  cin >> s;
  s = "^" + s;
  for (register int i = 0; i <= n; i++) {
    dp[i][1] = 1;
  }
  for (register int i = 2; i <= n + 1; i++) {
    for (register int j = 0; j <= n; j++) {
      memset(vis, false, sizeof(vis));
      for (register int k = j + 1; k <= n; k++) {
        if (vis[s[k] - 'a'] == false) {
          dp[j][i] =
              (dp[j][i] + dp[k][i - 1] < want ? dp[j][i] + dp[k][i - 1] : want);
          vis[s[k] - 'a'] = true;
        }
      }
    }
  }
  for (register int i = n; i >= 0; i--) {
    now = dp[0][i + 1];
    memset(vis, false, sizeof(vis));
    ans += (n - i) * (now < want ? now : want);
    want -= (now < want ? now : want);
  }
  if (want > 0) {
    printf("-1\n");
    return 0;
  }
  printf("%lld\n", ans);
  return 0;
}
