#include <bits/stdc++.h>
using namespace std;
long long dp[200][200];
int last[100];
int main(void) {
  int n;
  long long k;
  string s;
  cin >> n >> k >> s;
  memset(dp, 0, sizeof(dp));
  memset(last, 0, sizeof(last));
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    dp[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1];
      if (last[s[i - 1] - 'a']) dp[i][j] -= dp[last[s[i - 1] - 'a'] - 1][j - 1];
    }
    last[s[i - 1] - 'a'] = i;
  }
  long long t, res = 0;
  for (int i = n; i >= 0; i--) {
    t = min(dp[n][i], k);
    res += t * (n - i);
    k -= t;
    if (k == 0) break;
  }
  if (k) res = -1;
  cout << res;
  return 0;
}
