#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
using ull = unsigned long long int;
template <typename Arg1>
void debug_out(const char* name, Arg1&& arg1) {
  cerr << name << " = " << arg1 << " ]"
       << "\n";
}
template <typename Arg1, typename... Args>
void debug_out(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1 << ",";
  debug_out(comma + 1, args...);
}
constexpr long long inf = 2e9, ninf = -2e9;
constexpr long double eps = 1e-9;
constexpr long long mod = 1e9 + 7;
constexpr long long N = 100 + 5, M = 2e5 + 5;
long long n, k;
string s;
long long pref[N][N];
long long last[26];
void DONT_ASSUME_BLINDLY() {
  memset(last, -1, sizeof(last));
  cin >> n >> k >> s;
  s = "#" + s;
  pref[0][0] = 1;
  for (long long i = (1); i <= (n); ++i) {
    for (long long j = (0); j < (i); ++j) {
      pref[i][j] += pref[i - 1][j];
      pref[i][j + 1] += pref[i - 1][j];
    }
    if (last[s[i] - 'a'] != -1) {
      long long ind = last[s[i] - 'a'];
      assert(ind >= 1 && ind < i);
      for (long long j = (0); j <= (ind); ++j) {
        pref[i][j + 1] -= pref[ind - 1][j];
      }
    }
    last[s[i] - 'a'] = i;
  }
  long long cost = 0;
  for (long long i = (n); i >= (0); --i) {
    if (k <= 0) break;
    long long rem = min(k, pref[n][i]);
    k -= rem;
    cost += (n - i) * rem;
  }
  if (k <= 0)
    cout << cost << '\n';
  else
    cout << -1 << '\n';
}
int32_t main() {
  cin.tie(0)->sync_with_stdio(0);
  long long tc = 1;
  for (long long i = 1; i <= tc; i++) {
    DONT_ASSUME_BLINDLY();
  }
  cerr << "[time:" << 1.0 * clock() / CLOCKS_PER_SEC << "s] ";
  return 0;
}
