#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
bool check(int n) {
  int sum = 0;
  while (n) {
    sum += n % 10;
    n /= 10;
  }
  return !(sum % 4);
}
int main() {
  long long n, k;
  cin >> n >> k;
  char str[102];
  cin >> str;
  long long dp[n][101];
  for (int i = 0; i <= n; ++i) {
    dp[n - 1][i] = 0;
  }
  int lastOccur[27];
  memset(lastOccur, -1, sizeof(lastOccur));
  dp[n - 1][1] = 1;
  lastOccur[str[n - 1] - 'a'] = n - 1;
  for (int i = n - 2; i >= 0; i--) {
    dp[i][0] = 0;
    for (int j = 1; j <= n; ++j) {
      dp[i][j] = dp[i + 1][j];
      dp[i][j] += dp[i + 1][j - 1];
    }
    dp[i][1] += 1;
    if (lastOccur[str[i] - 'a'] > 0) {
      int idx = lastOccur[str[i] - 'a'];
      if (idx != n - 1) {
        idx += 1;
        for (int j = 1; j <= n; ++j) {
          dp[i][j] -= dp[idx][j - 1];
        }
      }
      dp[i][1] -= 1;
    }
    lastOccur[str[i] - 'a'] = i;
  }
  long long sum = 0;
  long long cnt = 0;
  for (int i = n; i > 0; i--) {
    if (cnt + dp[0][i] <= k) {
      sum += (n - i) * dp[0][i];
      cnt += dp[0][i];
    } else {
      sum += (n - i) * (k - cnt);
      cnt += (k - cnt);
    }
    if (cnt == k) break;
  }
  if (cnt + 1 == k) {
    sum += n;
    cnt++;
  }
  if (cnt != k) {
    cout << "-1\n";
  } else {
    cout << sum << "\n";
  }
}
