#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long longinf = 1LL << 60;
const long long mod = 1e9 + 7;
const long double eps = 1e-10;
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
void solve() {
  int n;
  long long k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<int> last(26, -1);
  vector<vector<long long>> dp(n + 1, vector<long long>(105));
  dp[0][0] = 1;
  for (int i = (int)(0); i < (int)(n); i++) {
    int id = s[i] - 'a';
    for (int k = (int)(0); k < (int)(101); k++) {
      for (int j = (int)(last[id] + 1); j < (int)(i + 1); j++) {
        dp[i + 1][k + 1] += dp[j][k];
        chmin(dp[i + 1][k + 1], 1e12);
      }
    }
    last[id] = i;
  }
  vector<long long> cnt(105);
  for (int i = (int)(0); i < (int)(101); i++) {
    for (int j = (int)(0); j < (int)(n + 1); j++) {
      cnt[i] += dp[j][i];
      chmin(cnt[i], 1e12);
    }
  }
  long long ans = 0;
  long long rem = k;
  for (int i = (int)((101) - 1); i >= (int)(0); i--) {
    if (cnt[i] >= rem) {
      ans += rem * (n - i);
      rem = 0;
      break;
    } else {
      ans += cnt[i] * (n - i);
      rem -= cnt[i];
    }
  }
  if (rem) {
    cout << -1 << '\n';
  } else {
    cout << ans << '\n';
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int T = 1;
  while (T--) solve();
  return 0;
}
