#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1);
const long long mod = 1e9 + 7;
const long double eps = 1e-9;
const int maxn = 1e5 + 10;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long dp[105][105];
int mp[500];
signed main() {
  long long n, k;
  scanf("%lld%lld", &n, &k);
  char s[105];
  scanf("%s", s + 1);
  for (int i = 0; i <= n; i++) dp[i][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
      int pre = mp[s[i]];
      if (pre) {
        dp[i][j] = min(dp[i - 1][j] + dp[i - 1][j - 1] - dp[pre - 1][j - 1], k);
      } else {
        dp[i][j] = min(dp[i - 1][j] + dp[i - 1][j - 1], k);
      }
    }
    mp[s[i]] = i;
  }
  long long sum = 0, ans = 0;
  for (int i = n; i >= 0; i--) {
    sum += dp[n][i];
    ans += (n - i) * dp[n][i];
    if (sum > k) {
      ans -= (sum - k) * (n - i);
      break;
    }
  }
  if (sum < k)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}
