#include <bits/stdc++.h>
using namespace std;
long long n, k;
string s;
long long dp[105][105];
long long run(long long idx, long long now) {
  if (now == 0) {
    return 1;
  }
  if (idx == n) {
    if (now == 0)
      return 1;
    else
      return 0;
  }
  if (dp[idx][now] != -1) return dp[idx][now];
  if (idx == n) return 1;
  bool f[26];
  memset(f, false, sizeof f);
  long long ans = 0;
  for (long long i = idx; i < n; i++) {
    if (!f[s[i] - 'a']) {
      ans += run(i + 1, now - 1);
      f[s[i] - 'a'] = true;
      ans = min(ans, k);
    }
  }
  ans += run(n, now);
  ans = min(ans, k);
  return dp[idx][now] = ans;
}
int main() {
  memset(dp, -1, sizeof dp);
  cin >> n >> k;
  cin >> s;
  long long w = k;
  long long ans = 0;
  for (long long i = n; i >= 0; i--) {
    long long t = run(0, i);
    if (t < k) {
      k -= t;
      ans += t * i;
    } else {
      ans += k * i;
      cout << n * w - ans;
      return 0;
    }
  }
  cout << -1;
}
