#include <bits/stdc++.h>
using namespace std;
long long int dp[105][26];
int used[105][26];
int main() {
  long long int n, k, pos;
  cin >> n >> k;
  string s;
  cin >> s;
  for (int i = 0; i < n; i++) {
    dp[1][s[i] - 'a'] = 1;
  }
  for (int end = 0; end < n; end++) {
    for (int len = end + 1; len >= 2; len--) {
      int aux[26] = {0};
      char c = s[end];
      int no = c - 'a';
      if (used[len][no]) dp[len][no] = 0;
      for (int pos = end - 1; pos >= 0; pos--) {
        if (!aux[s[pos] - 'a']) {
          dp[len][no] += dp[len - 1][s[pos] - 'a'];
          if (dp[len][no] > 1e12) dp[len][no] = 1e12;
        }
        aux[s[pos] - 'a'] = 1;
      }
      used[len][no] = 1;
    }
  }
  long long int cost = 0;
  long long int number = 0;
  for (int len = n; len >= 1; len--) {
    for (int c = 0; c < 26; c++) {
      if (number + dp[len][c] <= k) {
        number += dp[len][c];
        cost += (dp[len][c] * (n - len));
      } else {
        long long int rem = k - number;
        cost += (rem * (n - len));
        number = k;
      }
    }
  }
  if (number == k)
    cout << cost;
  else if (number == k - 1)
    cout << cost + n;
  else
    cout << "-1";
}
