#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 5;
int n;
long long k;
string s;
int pre[maxn], lst[maxn];
long long dp[maxn][maxn];
int main() {
  scanf("%d%lld", &n, &k);
  cin >> s;
  s = "!" + s;
  for (int i = 1; i <= n; i++) {
    pre[i] = lst[s[i] - 'a'];
    lst[s[i] - 'a'] = i;
  }
  for (int i = 0; i <= n; i++) dp[i][0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= i; j++) {
      dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1];
      if (pre[i]) dp[i][j] -= dp[pre[i] - 1][j - 1];
    }
  long long ret = 0;
  for (int i = n; i >= 0; i--) {
    if (k >= dp[n][i]) {
      ret += (long long)(n - i) * dp[n][i];
      k -= dp[n][i];
    } else {
      ret += (long long)(n - i) * k;
      k = 0;
      break;
    }
  }
  if (k != 0)
    printf("-1");
  else
    printf("%lld", ret);
  return 0;
}
