#include <bits/stdc++.h>
using namespace std;
long long f[110][110][26], s[110][110], ans, k;
int n;
char str[110];
int main() {
  scanf("%d%lld%s", &n, &k, str + 1);
  for (int i = 1; i <= n; i++) {
    f[i][1][str[i] - 'a'] = 1;
    for (int j = 1; j <= i; j++)
      for (int c = 0; c < 26; c++) {
        if (c + 'a' == str[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 (int i = n; ~i; ans += s[n][i] * (n - i), k -= s[n][i], i--)
    if (s[n][i] > k) {
      ans += k * (n - i), k = 0;
      break;
    }
  printf("%lld\n", k ? -1ll : ans);
}
