#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long modularExponentiation(long long base, long long power,
                                long long mod) {
  long long ans = 1;
  while (power > 0) {
    if (power & 1) ans = (ans * base) % mod;
    power = power >> 1;
    base = (base * base) % mod;
  }
  return ans;
}
const int N = 110;
string str;
int n, last[N];
long long k, dp[N][N];
void solve() {
  cin >> n >> k;
  cin >> str;
  for (int i = 0; i <= N - 1; ++i) dp[0][i] = 0;
  dp[0][0] = 1;
  memset(last, 0, sizeof(last));
  for (int i = 0; i <= n - 1; ++i) {
    dp[i + 1][0] = 1;
    for (int j = 1; j <= i + 1; ++j) {
      dp[i + 1][j] = dp[i][j];
      dp[i + 1][j] += dp[i][j - 1];
      if (last[str[i] - 'a']) dp[i + 1][j] -= dp[last[str[i] - 'a'] - 1][j - 1];
    }
    last[str[i] - 'a'] = i + 1;
  }
  long long ans = 0;
  for (int i = n; i >= 0; --i) {
    long long req = min(k, dp[n][i]);
    ans += (n - i) * req;
    k -= req;
    if (k == 0) break;
  }
  if (k)
    cout << -1 << "\n";
  else
    cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
