#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
long long modx(long long a) { return (a % MOD + MOD) % MOD; }
const int MAXN = 102;
long long N, K, dp[MAXN][MAXN], cost;
map<char, int> last;
string str;
int main() {
  cin >> N >> K >> str;
  dp[0][0] = 1;
  for (int i = 0; i < N; i++) {
    last[str[i]] = -1;
  }
  long long subtract;
  for (int i = 1; i <= N; i++) {
    dp[i][0] = 1;
    for (int j = 1; j <= N; j++) {
      dp[i][j] += dp[i - 1][j] + dp[i - 1][j - 1];
      if (last[str[i - 1]] == -1) {
        subtract = 0;
      } else {
        subtract = dp[last[str[i - 1]] - 1][j - 1];
      }
      dp[i][j] -= subtract;
    }
    last[str[i - 1]] = i;
  }
  int ind = N;
  long long sum = 0;
  while (ind >= 0 && sum <= K) {
    sum += dp[N][ind];
    if (sum > K) {
      cost += (K - sum + dp[N][ind]) * (N - ind);
    } else {
      cost += dp[N][ind] * (N - ind);
    }
    ind--;
  }
  if (ind == -1 && sum < K) {
    cout << -1;
  } else {
    cout << cost;
  }
  return 0;
}
