#include <bits/stdc++.h>
using namespace std;
vector<int> adj[305];
long long maxi, dp[105][105];
long long solve(int pos, int k) {
  if (k == maxi) return 1;
  if (dp[pos][k] != -1) return dp[pos][k];
  long long res = 0;
  for (int i = 'a'; i <= 'z'; i++) {
    auto next = upper_bound(adj[i].begin(), adj[i].end(), pos);
    if (next == adj[i].end()) continue;
    res += solve(*next, k + 1);
  }
  return dp[pos][k] = res;
}
int main() {
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  for (int i = 0; i < n; i++) adj[s[i]].push_back(i + 1);
  long long res = 0, cnt = 0;
  for (int i = n; i >= 0 and cnt < k; i--) {
    memset(dp, -1, sizeof dp);
    maxi = i;
    long long aux = solve(0, 0);
    aux = min(k - cnt, aux);
    res += aux * (n - i);
    cnt += aux;
  }
  if (cnt < k)
    cout << -1 << endl;
  else
    cout << res << endl;
  return 0;
}
