#include <bits/stdc++.h>
using namespace std;
long long n, m, K, ans, W[300], dp[103][103];
string a;
int main() {
  scanf("%lld%lld", &n, &K);
  cin >> a;
  a = "$" + a;
  for (register int i = 0; i <= n; ++i) dp[i][0] = 1;
  for (register int i = 1; i <= n; ++i) {
    for (register int j = 1; j <= i; ++j) {
      dp[i][j] = dp[i - 1][j];
      if (!W[a[i]])
        dp[i][j] += dp[i - 1][j - 1];
      else
        dp[i][j] += dp[i - 1][j - 1] - dp[W[a[i]] - 1][j - 1];
    }
    W[a[i]] = i;
  }
  for (register int i = n; i >= 0; --i) {
    if (K <= dp[n][i]) {
      ans += K * (n - i);
      return !printf("%lld", ans);
    }
    K -= dp[n][i];
    ans += dp[n][i] * (n - i);
  }
  puts("-1");
}
