#include <bits/stdc++.h>
using namespace std;
const long long N = 120;
string s;
int n, k, f[N], dp[N][N];
bool solved[N][N];
long long ans = 0;
int calc(int i, int c) {
  if (c == 0) {
    return 1;
  }
  if (i == n) {
    return 0;
  }
  if (solved[i][c]) {
    return dp[i][c];
  }
  for (int j = 0; j < 26; j++) {
    for (int k = i; k < n; k++) {
      if (s[k] - 'a' == j) {
        dp[i][c] += calc(k + 1, c - 1);
        dp[i][c] = min(dp[i][c], 100);
        break;
      }
    }
  }
  solved[i][c] = 1;
  return dp[i][c];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k >> s;
  for (int i = 0; i < s.size(); i++) {
    f[s[i] - 'a']++;
  }
  for (int i = 0; i <= n; i++) {
    int c = calc(0, n - i);
    if (c <= k) {
      k -= c;
      ans += i * c;
    } else {
      ans += i * k;
      k = 0;
    }
  }
  if (k != 0) {
    cout << -1;
  } else {
    cout << ans;
  }
}
