#include <bits/stdc++.h>
using namespace std;
long long n, k, dp[105][105], pre[205];
char a[105];
signed main() {
  cin >> n >> k;
  scanf("%s", a + 1);
  dp[0][0] = 1;
  for (long long i = 1; i <= n; pre[a[i]] = i, i++)
    for (long long j = i; j >= 0; j--)
      dp[i][j] =
          j == 0 ? dp[i - 1][j]
                 : dp[i - 1][j] + dp[i - 1][j - 1] -
                       dp[(pre[a[i]] - 1) == -1 ? n : (pre[a[i]] - 1)][j - 1];
  long long ans = 0;
  for (long long i = n; i >= 0 && k; i--) {
    ans += min(k, dp[n][i]) * (n - i);
    k -= min(k, dp[n][i]);
  }
  if (k) ans = -1;
  cout << ans << "\n";
  return 0;
}
