#include <bits/stdc++.h>
using namespace std;
long long dp[300][300];
int main() {
  int n;
  long long k;
  string s;
  cin >> n >> k;
  cin >> s;
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j > 0; j--) {
      if (j == 1)
        dp[j][s[i]] = 1;
      else {
        dp[j][s[i]] = 0;
        for (char c = 'a'; c <= 'z'; c++) {
          dp[j][s[i]] += dp[j - 1][c];
          if (dp[j][s[i]] >= k) dp[j][s[i]] = k;
        }
      }
    }
  }
  long long ans = 0;
  dp[0]['a'] = 1;
  for (int i = n; i >= 0; i--) {
    for (char c = 'a'; c <= 'z'; c++) {
      if (dp[i][c] != 0) {
        long long ile = min(dp[i][c], k);
        ans += (n - i) * ile;
        k -= ile;
      }
    }
    if (k == 0) break;
  }
  if (k == 0)
    cout << ans << endl;
  else
    cout << -1 << endl;
  return 0;
}
