#include <bits/stdc++.h>
using std::cin, std::cout, std::string, std::min;
constexpr int N = 109;
constexpr int DIGITS = 26;
using ll = long long int;
struct digitCounterMap {
  ll counter[DIGITS];
  ll total;
};
digitCounterMap digitCounter[2][N];
ll uniquesSubsequences[N];
void preProcess(string &inputString, int length) {
  int parity = 0;
  for (int i = 0; i < length; i++) {
    digitCounter[parity][i].total = 1;
    for (int ch = 0; ch < DIGITS; ch++) digitCounter[parity][i].counter[ch] = 0;
  }
  uniquesSubsequences[0] = 1;
  for (int len = 1; len <= length; len++) {
    parity ^= 1;
    for (int i = 0; i < len - 1; i++) {
      digitCounter[parity][i].total = 0;
      for (int ch = 0; ch < DIGITS; ch++)
        digitCounter[parity][i].counter[ch] = 0;
    }
    for (int i = len - 1; i < length; i++) {
      int index = inputString[i] - 'a';
      digitCounter[parity][i].total =
          (i != 0 ? digitCounter[parity][i - 1].total : 0);
      for (int ch = 0; ch < DIGITS; ch++)
        digitCounter[parity][i].counter[ch] =
            (i != 0 ? digitCounter[parity][i - 1].counter[ch] : 0);
      ll newCount = (i != 0 ? digitCounter[parity ^ 1][i - 1].total : 1);
      digitCounter[parity][i].total +=
          newCount - digitCounter[parity][i].counter[index];
      digitCounter[parity][i].counter[index] = newCount;
    }
    uniquesSubsequences[len] = digitCounter[parity][length - 1].total;
  }
}
int main() {
  int length;
  ll k;
  cin >> length >> k;
  string inputString;
  cin >> inputString;
  preProcess(inputString, length);
  ll cost = 0, lengthCounter = length;
  while (k > 0 && lengthCounter >= 0) {
    cost +=
        (length - lengthCounter) * min(k, uniquesSubsequences[lengthCounter]);
    k -= min(k, uniquesSubsequences[lengthCounter]);
    lengthCounter--;
  }
  if (k)
    cout << -1 << '\n';
  else
    cout << cost << '\n';
  return 0;
}
