#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1.0);
long long dp[105][105];
void solve() {
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  for (long long i = 0; i < (long long)s.size(); ++i) {
    dp[i][1] = 1;
  }
  for (long long i = 0; i < n; ++i) {
    for (long long j = 2; j < i + 2; ++j) {
      vector<bool> a(26);
      for (long long k = i - 1; k >= 0; --k) {
        if (a[s[k] - 'a'] == 0) {
          if (dp[i][j] <= 1e16) dp[i][j] += dp[k][j - 1];
        }
        a[s[k] - 'a'] = 1;
      }
    }
  }
  long long ans = 0;
  for (long long j = n; j >= 1; --j) {
    vector<bool> a(26);
    for (long long i = n - 1; i >= 0; --i) {
      if (a[s[i] - 'a'] == 0) {
        long long diff = min(dp[i][j], k);
        k -= diff;
        ans += (n - j) * diff;
      }
      a[s[i] - 'a'] = 1;
    }
  }
  if (k == 1) {
    --k;
    ans += n;
  }
  if (k)
    cout << -1 << '\n';
  else
    cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
