#include <bits/stdc++.h>
using namespace std;
double const EPS = 1e-12, PI = acos(-1);
const int N = 2e5 + 9, M = 1e7 + 9, OO = 1e9 + 7, MOD = 1e9 + 7,
          MOD2 = 998244353;
const long long inf = 1e13;
int lst[109][26], n;
long long mem[109][109];
long long add(long long x, long long y) {
  x += y;
  if (x > inf) x = inf;
  return x;
}
long long solve(int idx, int left) {
  if (!left) return 1;
  if (idx == n) return 0;
  long long& ret = mem[idx][left];
  if (~ret) return ret;
  ret = 0;
  for (int i = 0; i < 26; ++i) {
    if (lst[idx][i] != -1) ret = add(ret, solve(lst[idx][i] + 1, left - 1));
  }
  return ret;
}
int main() {
  cout << fixed << setprecision(12), ios::sync_with_stdio(false),
      cin.tie(nullptr), cout.tie(nullptr);
  long long k;
  string str;
  cin >> n >> k >> str;
  memset(mem, -1, sizeof mem);
  memset(lst, -1, sizeof lst);
  for (int i = n - 1; i >= 0; --i) {
    for (int j = 0; j < 26; ++j) lst[i][j] = lst[i + 1][j];
    lst[i][str[i] - 'a'] = i;
  }
  --k;
  long long ans = 0;
  for (int i = n - 1; i >= 0 && k; --i) {
    long long ret = min(k, solve(0, i));
    k -= ret;
    ans += ret * (n - i);
  }
  if (k)
    cout << -1;
  else
    cout << ans;
  return 0;
}
