#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e13;
long long int sdp[26][105];
long long int dp[105][105];
int main() {
  int n;
  long long int k;
  scanf("%d %lld", &n, &k);
  string s;
  cin >> s;
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    int ch = s[i - 1] - 'a';
    dp[i][0] = 1;
    for (int l = 1; l <= n; l++) {
      dp[i][l] = dp[i - 1][l] + dp[i - 1][l - 1] - sdp[ch][l];
      sdp[ch][l] = dp[i - 1][l - 1];
      if (dp[i][l] > INF) dp[i][l] = INF;
    }
  }
  long long int Total = 0;
  for (int l = 0; l <= n; l++) Total += dp[n][l];
  if (k <= Total) {
    long long int Cost = 0;
    for (int l = n; l >= 0; l--) {
      long long int Give = min(k, dp[n][l]);
      k -= Give;
      Cost += Give * (n - l);
    }
    printf("%lld", Cost);
  } else
    printf("-1");
}
