#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long k;
  cin >> n >> k;
  string s;
  cin >> s;
  int dp[n + 1][n + 1];
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  vector<int> vis(26, 0);
  for (int i = 1; i <= n; i++) dp[1][i] = 1, vis[s[i - 1] - 'a'] = 1;
  for (int len = 2; len <= n; len++) {
    for (int i = 1; i <= n; i++) {
      vector<int> vis(26, 0);
      for (int j = i + 1; j <= n; j++) {
        if (vis[s[j - 1] - 'a'] == 0) {
          dp[len][i] += dp[len - 1][j];
          vis[s[j - 1] - 'a'] = 1;
        }
      }
    }
  }
  long long cost = 0;
  for (int len = n; len >= 0; len--) {
    vector<int> vis(26, 0);
    for (int i = 1; i <= n; i++) {
      if (!vis[s[i - 1] - 'a']) {
        k -= dp[len][i];
        if (k <= 0) {
          cost += (k + dp[len][i]) * (n - len);
          k = 0;
          break;
        } else
          cost += dp[len][i] * (n - len);
        vis[s[i - 1] - 'a'] = 1;
      }
    }
    if (k <= 0) break;
  }
  if (k == 1) cost += n, k -= 1;
  if (k <= 0)
    cout << cost << endl;
  else
    cout << -1 << endl;
}
