#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long mod = 1e9 + 7;
const int phash = 3;
const long long modhash = 1000000000000000003;
const long long INF = 1e12;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  k--;
  string s;
  cin >> s;
  vector<vector<int> > lst(n + 1, vector<int>(26, -1));
  for (int i = 0; i < n; i++) {
    if (i > 0) {
      for (int j = 0; j < 26; j++) lst[i][j] = lst[i - 1][j];
    }
    lst[i][s[i] - 'a'] = i;
  }
  vector<vector<long long> > dp(n + 1, vector<long long>(n + 1, 0));
  for (int i = 0; i < n; i++) dp[i][1] = 1;
  for (int len = 2; len < n; len++)
    for (int i = 1; i < n; i++)
      for (int j = 0; j < 26; j++)
        if (lst[i - 1][j] != -1)
          dp[i][len] = min(INF, dp[i][len] + dp[lst[i - 1][j]][len - 1]);
  long long ans = 0;
  for (int len = n - 1; len >= 1; len--) {
    long long cur = 0;
    for (int j = 0; j < 26; ++j)
      if (lst[n - 1][j] != -1) cur = min(INF, cur + dp[lst[n - 1][j]][len]);
    if (cur >= k) {
      ans += k * (n - len);
      k = 0;
      break;
    } else {
      ans += cur * (n - len);
      k -= cur;
    }
  }
  if (k == 1) {
    k--;
    ans += n;
  }
  if (k > 0)
    cout << -1;
  else
    cout << ans;
}
