#include <bits/stdc++.h>
using namespace std;
const long long maxn = 109;
long long n, k, pre[maxn], f[maxn][maxn], ans;
char a[maxn];
int main() {
  cin >> n >> k >> (a + 1);
  f[0][0] = 1;
  for (long long i = 1; i <= n; i++) {
    f[i][0] = 1;
    for (long long j = 1; j <= i; j++) {
      f[i][j] += f[i - 1][j - 1] + f[i - 1][j];
      if (pre[a[i] - 'a']) f[i][j] -= f[pre[a[i] - 'a'] - 1][j - 1];
      if (f[i][j] > k) f[i][j] = k;
    }
    pre[a[i] - 'a'] = i;
  }
  for (long long i = n; i >= 0; i--) {
    long long x = min(k, f[n][i]);
    k -= x;
    ans += x * (n - i);
  }
  if (k) ans = -1;
  cout << ans;
  return 0;
}
