#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-18;
const double DEPS = 1e-9;
const long double PI = 3.141592653589793238;
const long long MOD = (long long)1e9 + 7;
const int N = (int)(5e5) + 10;
void inp() {}
void out() {}
int n;
long long dp[102][102], ans, k;
string x;
long long rec(int id, int v) {
  if (!v || id == n) return !v;
  long long& dp = ::dp[id][v];
  if (dp != -1) return dp;
  dp = 0;
  for (int i = 0; i < 26; i++) {
    for (int j = id; j < n; j++) {
      if (x[j] - 'a' == i) {
        dp += rec(j + 1, v - 1);
        dp = min(dp, (long long)1e12);
        break;
      }
    }
  }
  return dp;
}
int main() {
  inp();
  cin >> n >> k >> x;
  memset(dp, -1, sizeof(dp));
  for (long long i = 0; i <= n; i++) {
    long long get = rec(0, n - i);
    if (get < k) {
      k -= get;
      ans += get * i;
    } else {
      ans += k * i;
      k = 0;
      break;
    }
  }
  if (k)
    puts("-1");
  else
    printf("%lld", ans);
}
