#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 105;
long long dp1[MAXN][MAXN];
char C[MAXN];
int main() {
  long long n, k;
  cin >> n >> k;
  cin >> C + 1;
  dp1[0][0] = 1;
  dp1[1][1] = 1;
  dp1[1][0] = 1;
  for (long long i = 2; i <= n; i++) {
    for (long long j = 0; j <= n; j++) {
      dp1[i][j] = dp1[i - 1][j] + dp1[i - 1][j - 1];
      long long idx = -1;
      for (long long k = i - 1; k >= 1; k--) {
        if (C[k] == C[i]) {
          idx = k;
          break;
        }
      }
      if (idx != -1) dp1[i][j] -= dp1[idx - 1][j - 1];
    }
  }
  long long ans = 0;
  bool f = 1;
  for (long long i = n; i >= 0; i--) {
    if (dp1[n][i] <= k) {
      k -= dp1[n][i];
      ans += (n - i) * dp1[n][i];
    } else {
      ans += k * (n - i);
      k = 0;
    }
    if (k == 0) {
      f = 0;
      break;
    }
  }
  if (!f)
    cout << ans << endl;
  else
    cout << -1 << endl;
}
