#include <bits/stdc++.h>
using namespace std;
typedef priority_queue<long long, vector<long long>, greater<long long>>
    minHeap;
long long INF = 1e17;
const int N = 2e6 + 33;
const long long MD = 24;
inline long long mul(long long a, long long b) { return (a * b) % MD; }
inline long long po(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) ans = mul(ans, a);
    a = mul(a, a);
    b /= 2;
  }
  return ans;
}
long long n, m, t, k;
long long arr[N];
long long x;
string s;
long long dp[110][110];
int last[110][30];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k >> s;
  memset(last, -1, sizeof last);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 26 && i > 0; j++) {
      last[i][j] = last[i - 1][j];
    }
    last[i][s[i] - 'a'] = i;
  }
  for (int i = 0; i < n; i++) {
    dp[i][1] = 1;
  }
  for (int i = 2; i <= s.size(); i++) {
    for (int j = 1; j < n; j++) {
      for (int z = 0; z < 26; z++) {
        if (last[j - 1][z] == -1) continue;
        dp[j][i] += dp[last[j - 1][z]][i - 1];
        dp[j][i] = min(dp[j][i], (long long)1e12);
      }
    }
  }
  long long ans = 0;
  for (int i = n; i > 0; i--) {
    long long sum = 0;
    for (int j = 0; j < 26; j++) {
      if (last[n - 1][j] == -1) continue;
      sum += dp[last[n - 1][j]][i];
      sum = min(sum, (long long)1e12);
    }
    if (sum < k) {
      k -= sum;
      ans += sum * (n - i);
    } else {
      ans += k * (n - i);
      cout << ans;
      return 0;
    }
  }
  k--;
  ans += n;
  if (!k)
    cout << ans;
  else
    cout << -1;
  return 0;
}
