#include <bits/stdc++.h>
const double PI = acos(-1.0);
using namespace std;
void fast_in_out() {
  std::ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
}
int dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
int dy[] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
const long double eps = 1e-9;
const long long mod = 1e9 + 7;
long long solution(vector<long long> A, int k) {
  const int N = A.size();
  if (N < k || N < 1 || k < 1) return 0;
  if (N == k) return 1;
  vector<long long> v1(N, 0);
  vector<long long> v2(N, 0);
  vector<long long> v3(N, 0);
  v2[N - 1] = 1;
  v3[A[N - 1] - 1] = 1;
  for (int i = N - 2; i >= 0; i--) {
    v2[i] = v2[i + 1];
    if (v3[A[i] - 1] == 0) {
      v2[i]++;
      v3[A[i] - 1] = 1;
    }
  }
  for (int j = 1; j < k; j++) {
    fill(v3.begin(), v3.end(), 0);
    v1[N - 1] = 0;
    for (int i = N - 2; i >= 0; i--) {
      v1[i] = v1[i + 1];
      v1[i] = v1[i] + v2[i + 1];
      v1[i] = v1[i] - v3[A[i] - 1];
      v3[A[i] - 1] = v2[i + 1];
    }
    v2 = v1;
  }
  return v1[0];
}
long long solve(string str, int k) {
  vector<long long> v;
  for (int i = 0; i < str.size(); i++) v.push_back(str[i] - 'a' + 1);
  return solution(v, k);
}
int main() {
  fast_in_out();
  string str;
  long long n, k;
  cin >> n >> k;
  long long ret = 0;
  long long ans = 0;
  cin >> str;
  map<char, char> mp;
  char ch = 'a';
  for (int i = 0; i < str.size(); i++) {
    if (mp.find(str[i]) == mp.end()) {
      mp[str[i]] = ch;
      ch++;
    }
    str[i] = mp[str[i]];
  }
  for (int i = n; i >= 0; i--) {
    if (ret >= k) break;
    long long x = solve(str, i);
    if (i == 1)
      x = mp.size();
    else if (i == 0)
      x = 1;
    if (x + ret <= k) {
      ans += (n - i) * x;
      ret += x;
      ;
      continue;
    }
    x = k - ret;
    ans += (n - i) * x;
    ret += x;
    break;
  }
  if (ret == k)
    cout << ans << '\n';
  else
    cout << -1 << '\n';
  return 0;
}
