#include <bits/stdc++.h>
using namespace std;
void Solve() {
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<vector<long long>> dp(n, vector<long long>(n));
  for (char c = 'a'; c <= 'z'; ++c) {
    long long pos = find((s).begin(), (s).end(), c) - s.begin();
    if (pos != n) dp[0][pos] = 1;
  }
  for (long long i = 1; i < n; ++i) {
    for (long long j = 0; j < n; ++j) {
      vector<long long> was(26);
      for (long long k = j + 1; k < n; ++k) {
        if (!was[s[k] - 'a']) {
          dp[i][k] += dp[i - 1][j];
          was[s[k] - 'a'] = 1;
        }
      }
    }
  }
  long long ans = 0;
  for (long long i = n - 1; k && i >= 0; --i) {
    long long sm = accumulate((dp[i]).begin(), (dp[i]).end(), 0ll);
    if (sm > k) sm = k;
    k -= sm;
    ans += (n - i - 1) * sm;
  }
  if (k == 1) ans += n;
  cout << (k > 1 ? -1 : ans);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  Solve();
  return 0;
}
