#include <bits/stdc++.h>
using namespace std;
long long n, k, ans;
long long f[110][110][30], s[110][110];
string t;
signed main() {
  cin >> n >> k;
  cin >> t;
  t = " " + t;
  for (long long i = 1; i <= n; i++) {
    f[i][1][t[i] - 'a' + 1] = 1;
    for (long long j = 1; j <= i; j++) {
      for (long long c = 1; c <= 26; c++) {
        if (c + 'a' - 1 == t[i])
          f[i][j][c] += s[i - 1][j - 1];
        else
          f[i][j][c] += f[i - 1][j][c];
        if (f[i][j][c] > k) f[i][j][c] = k;
        s[i][j] += f[i][j][c];
      }
      if (s[i][j] > k) s[i][j] = k;
    }
  }
  s[n][0] = 1;
  for (long long i = n; i >= 0; i--) {
    if (s[n][i] > k) {
      ans += k * (n - i);
      k = 0;
      break;
    }
    ans += s[n][i] * (n - i);
    k -= s[n][i];
  }
  if (k)
    cout << -1;
  else
    cout << ans;
  return 0;
}
