#include <bits/stdc++.h>
using namespace std;
long long dp[105][105];
long long n, k;
string s;
bool used[26];
long long cnt[105];
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n >> k;
  cin >> s;
  dp[0][1] = 1;
  for (int i = 1; i < n; i++) {
    dp[i][1] = 1;
    memset(used, 0, sizeof(used));
    for (int j = i - 1; j >= 0; j--) {
      if (used[s[j] - 'a']) continue;
      used[s[j] - 'a'] = 1;
      for (int k = 1; k <= i + 1; k++) {
        dp[i][k] += dp[j][k - 1];
      }
    }
  }
  cnt[0] = 1;
  memset(used, 0, sizeof(used));
  for (int i = n - 1; i >= 0; i--) {
    if (used[s[i] - 'a']) continue;
    used[s[i] - 'a'] = 1;
    for (int j = 1; j <= 100; j++) {
      cnt[j] += dp[i][j];
    }
  }
  long long nsum = 0, ans = 0;
  for (long long i = n; i >= 0; i--) {
    if (nsum + cnt[i] >= k) {
      ans += (k - nsum) * (n - i);
      nsum = k;
      break;
    } else {
      ans += cnt[i] * (n - i);
      nsum += cnt[i];
    }
  }
  if (nsum < k)
    cout << -1 << '\n';
  else
    cout << ans << '\n';
}
