#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int last[26];
  memset(last, -1, sizeof(last));
  vector<vector<long long int>> dp(n + 1, vector<long long int>(n + 1, 0));
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    dp[i][0] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
      dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
      if (last[s[i - 1] - 'a'] != -1) {
        dp[i][j] -= dp[last[s[i - 1] - 'a'] - 1][j - 1];
      }
    }
    last[s[i - 1] - 'a'] = i;
  }
  long long int ans = 0;
  for (int i = n; i >= 0; i--) {
    if (k < dp[n][i]) {
      ans += (k) * (n - i);
      k = 0;
      break;
    } else
      ans += (n - i) * dp[n][i];
    k -= dp[n][i];
  }
  if (k > 0)
    cout << "-1" << '\n';
  else
    cout << ans << '\n';
}
