#include <bits/stdc++.h>
using namespace std;
long long dp[105][105];
int nxt[105][26];
string x;
long long n, k;
long long solve(int idx, int cnt) {
  if (idx > n) return 0;
  if (!cnt) return 1;
  if (idx >= n) return 0;
  if (dp[idx][cnt] != -1) return dp[idx][cnt];
  long long ret = 0;
  for (int i = 0; i < 26; i++) {
    ret += solve(nxt[idx][i] + 1, cnt - 1);
    ret = min(ret, k);
  }
  return dp[idx][cnt] = ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  cin >> x;
  fill(nxt[n], nxt[n] + 26, n);
  for (int i = x.size() - 1; i >= 0; i--) {
    for (int j = 0; j < 26; j++) {
      nxt[i][j] = nxt[i + 1][j];
    }
    nxt[i][x[i] - 'a'] = i;
  }
  long long cost = 0;
  memset(dp, -1, sizeof dp);
  for (int i = n; i >= 0; i--) {
    long long cnt = min(k, solve(0, i));
    cost += cnt * (n - i);
    k -= cnt;
  }
  if (k > 0)
    cout << -1;
  else
    cout << cost;
  return 0;
}
