#include <bits/stdc++.h>
using namespace std;
long long n, k;
char ch;
int last[30];
long long dp[105][105];
int main() {
  cin >> n >> k;
  memset(last, -1, sizeof(last));
  for (int i = 0; i < n; i++) {
    dp[i][0] = 1;
  }
  dp[0][1] = 1;
  for (int i = 0; i < n; i++) {
    cin >> ch;
    if (i) {
      for (int j = 1; j < n + 1; j++) {
        dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
        if (last[ch - 'a'] > 0) dp[i][j] -= dp[last[ch - 'a'] - 1][j - 1];
        if (last[ch - 'a'] == 0 && j == 1) dp[i][j] -= 1;
      }
    }
    last[ch - 'a'] = i;
  }
  long long c = 0;
  long long kol;
  for (int i = n; i + 1 > 0; i--) {
    kol = min(dp[n - 1][i], k);
    c += kol * (n - i);
    k -= kol;
    if (k == 0) break;
  }
  if (k > 0)
    cout << -1;
  else
    cout << c;
  return 0;
}
