#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template <typename T>
using V = vector<T>;
template <typename T>
using VV = vector<vector<T>>;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 + 99);
const vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
template <typename T, typename U>
inline bool chmin(T& t, const U& u) {
  if (t > u) {
    t = u;
    return 1;
  }
  return 0;
}
template <typename T, typename U>
inline bool chmax(T& t, const U& u) {
  if (t < u) {
    t = u;
    return 1;
  }
  return 0;
}
template <typename T>
inline T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T, typename Y>
inline T mpow(T a, Y n) {
  T res = 1;
  for (; n; n >>= 1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}
bool comp(const string& s, const string& t) { return s.size() < t.size(); }
ll dp[110][110] = {};
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  V<string> v(0);
  VV<int> nex(n + 10, V<int>(26, INF));
  for (ll i = n - 1; (ll)0 <= i; --i) {
    for (ll j = 26 - 1; (ll)0 <= j; --j) {
      nex[i][j] = nex[i + 1][j];
    }
    nex[i][s[i] - 'a'] = i;
  }
  dp[0][0] = 1;
  for (ll i = 0; i < (ll)(n); ++i) {
    for (ll j = 0; j < (ll)(i + 1); ++j) {
      for (ll l = 0; l < (ll)(26); ++l) {
        if (nex[i][l] == INF) continue;
        dp[nex[i][l] + 1][j + 1] += dp[i][j];
      }
    }
  }
  ll ans = 0, cnt = 0;
  for (ll i = n + 1 - 1; (ll)0 <= i; --i) {
    cnt = 0;
    for (ll j = 0; j < (ll)(n + 1); ++j) {
      cnt += dp[j][i];
    }
    if (k - cnt >= 0) {
      k -= cnt;
      ans += (n - i) * cnt;
    } else {
      ans += (n - i) * k;
      k = 0;
      break;
    }
  }
  if (k == 0)
    cout << ans << '\n';
  else
    cout << -1 << '\n';
}
