#include <bits/stdc++.h>
using namespace std;
long long dp[105][105];
int main() {
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  fill(dp[0], dp[0] + n + 5, 1);
  for (int i = 1; i <= n; i++) {
    map<int, int> ma;
    ma.clear();
    for (int j = i; j <= n; j++) {
      dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1];
      if (ma[s[j - 1]] != 0) {
        dp[i][j] -= dp[i - 1][ma[s[j - 1]] - 1];
      }
      ma[s[j - 1]] = j;
    }
  }
  long long sum = 0;
  long long ans = 0;
  int i;
  for (i = n; i >= 0; i--) {
    sum += dp[i][n];
    if (sum >= k) {
      ans += (n - i) * (dp[i][n] - sum + k);
      break;
    }
    ans += (n - i) * dp[i][n];
  }
  if (i != -1)
    cout << ans << endl;
  else {
    cout << i << endl;
  }
  return 0;
}
