#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
unsigned long long n, k, dp[maxn][maxn][30], f[maxn];
int a[maxn];
string s;
void solve() {
  cin >> n >> k >> s;
  s = " " + s;
  for (int i = (1); i <= (n); ++i) a[i] = s[i] - 'a';
  memset(dp, 0, sizeof(dp));
  dp[0][0][26] = 1;
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j <= i; ++j)
      for (int c = 0; c <= 26; ++c) {
        if (a[i] != c) dp[i][j][c] += dp[i - 1][j][c];
        if (a[i] == c && j)
          for (int d = 0; d <= 26; ++d) dp[i][j][c] += dp[i - 1][j - 1][d];
      }
  for (int i = 0; i <= n; ++i)
    for (int c = 0; c <= 26; ++c) f[i] += dp[n][i][c];
  unsigned long long ans = 0;
  for (int i = n; i >= 0; --i)
    if (k > f[i]) {
      k -= f[i];
      ans += f[i] * (n - i);
    } else
      ans += k * (n - i), k = 0;
  if (k > 0)
    cout << "-1\n";
  else
    cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
