#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> dp(101, vector<long long>(101, -1));
long long n, k;
string s;
long long getans(int curr, int len) {
  if (len == 0) {
    return 1;
  }
  if (curr == n - 1) {
    return 0;
  }
  if (dp[curr][len] != -1) {
    return dp[curr][len];
  }
  vector<bool> seen(26, false);
  long long ret = 0;
  for (int i = curr + 1; i < n; i += 1) {
    if (!seen[s[i] - 'a']) {
      seen[s[i] - 'a'] = true;
      ret += getans(i, len - 1);
      ret = min(ret, k);
    }
  }
  return dp[curr][len] = ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(NULL);
  cin.tie(NULL);
  cin >> n >> k >> s;
  vector<int> v(26, n), vals;
  for (int i = 0; i < n; i += 1) {
    v[s[i] - 'a'] = min(v[s[i] - 'a'], i);
  }
  for (int i = 0; i < 26; i += 1) {
    if (v[i] != n) {
      vals.push_back(v[i]);
    }
  }
  long long sum = 0;
  for (int i = n - 1; i >= 0; i -= 1) {
    for (int j : vals) {
      long long val = getans(j, i);
      if (val >= k) {
        sum += k * (n - i - 1);
        k = 0;
      } else {
        sum += val * (n - i - 1);
        k -= val;
      }
    }
  }
  if (k == 1) {
    cout << sum + n;
  } else if (k == 0) {
    cout << sum;
  } else {
    cout << -1;
  }
}
