#include <bits/stdc++.h>
using namespace std;
long long dp[150 + 1][150 + 1];
int N, P[256];
long long K;
string A;
long long sum(long long a, long long b) {
  if (a >= 123456789012345 || b >= 123456789012345) return 123456789012345;
  if (a + b >= K) return 123456789012345;
  return a + b;
}
int main(void) {
  cin >> N >> K >> A;
  dp[N][0] = 1;
  for (int i = 1; i <= N; i++) {
    dp[i][1] = 1 + dp[i - 1][1];
    if (P[A[i - 1]] > 0) dp[i][1]--;
    P[A[i - 1]] = i;
  }
  for (int L = 2; L <= N; L++) {
    memset(P, 0, sizeof(P));
    for (int i = 1; i <= N; i++) {
      dp[i][L] = dp[i - 1][L] + dp[i - 1][L - 1];
      if (P[A[i - 1]] > 0) dp[i][L] -= dp[P[A[i - 1]] - 1][L - 1];
      P[A[i - 1]] = i;
    }
  }
  long long cost = 0;
  for (int L = N; L >= 0; L--) {
    if (K - dp[N][L] > 0) {
      cost += dp[N][L] * (long long)(N - L);
      K -= dp[N][L];
    } else {
      cost += (long long)K * (long long)(N - L);
      K = 0;
    }
    if (!K) break;
  }
  if (K)
    printf("-1\n");
  else
    printf("%lld\n", cost);
  return 0;
}
