#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int N = 1e2 + 7;
const int M = 1e6 + 7;
const long long mod = 1e9 + 7;
char s[N];
long long dp[N][N];
int pos[27];
signed main() {
  ios::sync_with_stdio(false);
  int n;
  long long k;
  cin >> n >> k;
  dp[0][0] = 1ll;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    dp[i][0] = 1ll;
    for (int j = 1; j <= i; j++) {
      dp[i][j] = dp[i - 1][j];
      dp[i][j] += dp[i - 1][j - 1];
      if (pos[s[i] - 'a']) dp[i][j] -= dp[pos[s[i] - 'a'] - 1][j - 1];
      if (dp[i][j] > k) dp[i][j] = k;
    }
    pos[s[i] - 'a'] = i;
  }
  long long ans = 0;
  for (int i = n; i + 1; i--) {
    if (dp[n][i] >= k) {
      ans += k * (n - i);
      k = 0;
      break;
    }
    ans += dp[n][i] * (n - i);
    k -= dp[n][i];
  }
  if (k > 0)
    cout << "-1\n";
  else
    cout << ans << "\n";
  return 0;
}
