#include <bits/stdc++.h>
using namespace std;
const int N = 100 + 1, C = 26 + 1;
int n, k;
string s;
long long ans[N];
long long sum[N][C];
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  cin >> n >> k;
  cin >> s;
  ans[0] = 1;
  for (int i = 0; i < n; ++i) {
    char c = s[i] - 'a';
    for (int j = i + 1; j >= 1; --j) {
      ans[j] += ans[j - 1] - sum[j - 1][c];
      sum[j - 1][c] = ans[j - 1];
    }
  }
  long long end_ans = 0;
  for (int i = n; i >= 0; --i) {
    if (k >= ans[i]) {
      end_ans += (n - i) * ans[i];
      k -= ans[i];
    } else {
      end_ans += (n - i) * k;
      k = 0;
      break;
    }
  }
  cout << (k ? -1 : end_ans) << '\n';
}
