#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c *x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug &operator<<(const c &) {
    return *this;
  }
};
long long __pow(long long x, long long y, long long M) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x) % M;
    y >>= 1;
    x = (x * x) % M;
  }
  return res % M;
}
long long __pow(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y >>= 1;
    x = (x * x);
  }
  return res;
}
long long mi(long long x, long long M) { return __pow(x, M - 2, M); }
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long add(long long a, long long b, long long M) { return (a + b) % M; }
long long mul(long long a, long long b, long long M) { return (a * b) % M; }
long long sub(long long a, long long b, long long M) { return (a - b + M) % M; }
long long div(long long a, long long b, long long M) {
  return (a * mi(b, M)) % M;
}
void umax(long long &a, long long b) { a = max(a, b); }
void umin(long long &a, long long b) { a = min(a, b); }
const long long N = 3e5 + 2, inf = 1e18, M = 998244353;
long long Test, n, m, k, query;
bool ok = 1;
void test_case() {
  cin >> n >> k;
  string s;
  cin >> s;
  s = '$' + s;
  vector<long long> last(26);
  vector<vector<long long>> dp(n + 1, vector<long long>(n + 1));
  dp[0][0] = 1;
  for (long long i = 1; i <= n; i++) {
    dp[i][0] = 1;
    for (long long j = 1; j <= n; j++) {
      dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
      if (last[s[i] - 'a']) dp[i][j] -= dp[last[s[i] - 'a'] - 1][j - 1];
    }
    last[s[i] - 'a'] = i;
  }
  long long ans = 0;
  for (long long i = n; i >= 0 && k; i--) {
    ans += min(k, dp[n][i]) * (n - i), k -= min(k, dp[n][i]);
    debug() << " ["
            << "ans"
               ": "
            << (ans)
            << "] "
               " ["
            << "k"
               ": "
            << (k) << "] ";
  }
  if (k)
    cout << -1 << endl;
  else
    cout << ans << endl;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  Test = 1;
  while (Test--) test_case();
  return 0;
}
