#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return (!b) ? a : gcd(b, a % b);
}
int n;
long long int k;
string s;
long long int dp[105][105];
int pre[105][26];
long long int inf = 1e12;
void solve() {
  cin >> n >> k;
  cin >> s;
  k -= 1;
  memset(pre, -1, sizeof pre);
  for (int i = 0; i <= n - 1; i++) {
    int ch = s[i] - 'a';
    if (i > 0) {
      for (int j = 0; j <= 25; j++) pre[i][j] = pre[i - 1][j];
    }
    pre[i][ch] = i;
  }
  for (int i = 0; i <= n - 1; i++) dp[i][1] = 1;
  for (int i = 1; i <= n; i++) {
    for (int len = 2; len < n; len++) {
      for (int j = 0; j <= 25; j++) {
        if (pre[i - 1][j] != -1)
          dp[i][len] = min(inf, dp[i][len] + dp[pre[i - 1][j]][len - 1]);
      }
    }
  }
  long long int cst = 0;
  for (int len = n - 1; len >= 1; len--) {
    long long int ans = 0;
    for (int j = 0; j <= 25; j++) {
      if (pre[n - 1][j] != -1) ans += dp[pre[n - 1][j]][len];
    }
    if (k > ans) {
      k -= ans;
      cst += (n - len) * ans;
    } else {
      cst += (n - len) * k;
      k = 0;
      break;
    }
  }
  if (k == 1) {
    cst += n;
    k -= 1;
  }
  if (k > 0) {
    cout << -1;
  } else {
    cout << cst;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}
