#include <bits/stdc++.h>
using namespace std;
bool ooo = 1;
struct Dbg {
  template <typename T>
  Dbg& operator,(const T& v) {
    cout << v << ", ";
    return *this;
  }
} Dbg;
struct _ {
  _() { ooo = 0; }
} _;
const long long N = 1e6 + 6, mod = 1e9 + 7;
long long k, ans = 0, cnt = 0, n, a[200], tmp1[200], tmp2[200], tmp3[200];
string s;
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  if (ooo) return 0;
  cin >> n >> k >> s, a[0] = 0;
  vector<long long> v;
  for (long long i = 0; i <= n - 1; ++i) {
    if (!a[(long long)s[i]])
      cnt++, v.push_back(cnt), a[(long long)s[i]] = cnt;
    else
      v.push_back(a[(long long)s[i]]);
  }
  k--;
  for (long long i = n - 1; i >= 1; --i) {
    long long m = v.size(), res;
    if (m < 1 || m < i || i < 1) {
      res = 0;
      goto lol;
    }
    if (m == i) {
      res = 1;
      goto lol;
    }
    for (long long i = 0; i < 200; ++i) tmp1[i] = tmp2[i] = tmp3[i] = 0;
    tmp3[v[m - 1] - 1] = tmp2[m - 1] = 1;
    for (long long i = m - 2; i >= 0; i--) {
      tmp2[i] = tmp2[i + 1];
      if (tmp3[v[i] - 1] == 0) tmp3[v[i] - 1] = 1, tmp2[i]++;
    }
    for (long long j = 1; j < i; j++) {
      tmp1[m - 1] = 0, fill(tmp3, tmp3 + 200, 0);
      for (long long i = m - 2; i >= 0; i--)
        tmp1[i] = tmp1[i + 1], tmp1[i] = tmp1[i] + tmp2[i + 1],
        tmp1[i] = tmp1[i] - tmp3[v[i] - 1], tmp3[v[i] - 1] = tmp2[i + 1];
      for (long long i = 0; i < 200; i++) tmp2[i] = tmp1[i];
    }
    res = tmp1[0];
  lol:
    if (i == 1) res = cnt;
    if (k <= res) {
      ans += (n - i) * k, k = 0;
      break;
    } else
      k -= res, ans += res * (n - i);
  }
  if (k) k--, ans += n;
  cout << (k ? -1 : ans);
}
