#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  long long dp[n + 1][n + 1];
  memset(dp, 0, sizeof dp);
  for (int i = (0); i < (n + 1); ++i) dp[i][0] = 1;
  vector<long long> last(200, -1);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
      dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1];
      if (last[s[i - 1]] != -1) {
        dp[i][j] -= dp[last[s[i - 1]]][j - 1];
      }
      if (dp[i][j] >= 10000000000000LL) dp[i][j] = 10000000000000LL;
    }
    last[s[i - 1]] = i - 1;
  }
  int l = n;
  long long ans = 0;
  while (l >= 0 && k > 0) {
    if (dp[n][l] < k) {
      k -= dp[n][l];
      ans += (n - l) * dp[n][l];
    } else {
      ans += (n - l) * k;
      k = 0;
    }
    --l;
  }
  if (k <= 0)
    cout << ans << endl;
  else
    cout << -1 << endl;
}
