#include <bits/stdc++.h>
using namespace std;
unsigned long long min(unsigned long long x, unsigned long long y) {
  if (x < y) return x;
  return y;
}
unsigned long long max(unsigned long long x, unsigned long long y) {
  if (x < y) return y;
  return x;
}
long long min(long long x, long long y) {
  if (x < y) return x;
  return y;
}
long long max(long long x, long long y) {
  if (x < y) return y;
  return x;
}
int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  unsigned long long dp[101][101][26] = {0};
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      int sum = 0;
      for (int last = 0; last < 26; last++) {
        sum += dp[i - 1][j - 1][last];
        if (s[i - 1] - 'a' != last) {
          dp[i][j][last] = dp[i - 1][j][last];
        }
      }
      if (j == 1)
        dp[i][j][s[i - 1] - 'a'] = 1;
      else
        dp[i][j][s[i - 1] - 'a'] = sum;
    }
  }
  unsigned long long cost = 0;
  for (int size = n; size >= 0; size--) {
    unsigned long long tot = 0;
    for (int i = 0; i < 26; i++) {
      tot += dp[n][size][i];
    }
    if (size == 0) tot++;
    if (k >= tot) {
      k -= tot;
      cost += (n - size) * tot;
    } else {
      cost += (n - size) * k;
      k = 0;
    }
  }
  if (k) {
    cout << "-1\n";
    return 0;
  }
  cout << cost << "\n";
  return 0;
}
