#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 5;
const long long inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  long long n, k;
  char s[maxn];
  cin >> n >> k >> s + 1;
  vector<vector<long long>> dp(n + 1, vector<long long>(n + 1));
  vector<int> last(300, -1);
  dp[0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    dp[i][0] = 1;
    for (int j = 1; j <= i; ++j) {
      dp[i][j] += dp[i - 1][j - 1] + dp[i - 1][j];
      if (last[s[i]] >= (i - j)) {
        dp[i][j] -= dp[last[s[i]] - 1][last[s[i]] - (i - j)];
      }
    }
    last[s[i]] = i;
  }
  long long ans = 0;
  for (int i = 0; i <= n; ++i) {
    ans += min(k, dp[n][i]) * i;
    k -= min(k, dp[n][i]);
    if (k == 0) {
      cout << ans << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
