#include <bits/stdc++.h>
using namespace std;
const int sz = 1e5 + 10, mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, i, j;
  long long k, cost = 0;
  string s;
  cin >> n >> k >> s;
  int last[n + 1][26];
  long long dp[n][n + 1], f[n + 1];
  memset(last, -1, sizeof(last));
  memset(dp, 0, sizeof(dp));
  memset(f, 0, sizeof(f));
  for (i = 0; i <= n; i++) {
    for (j = 0; j < i; j++) {
      last[i][s[j] - 'a'] = j;
    }
  }
  dp[0][1] = 1;
  for (i = 1; i < n; i++) {
    for (int len = 1; len <= n; len++) {
      if (i + 1 < len) break;
      if (len == 1) {
        dp[i][len] = 1;
        continue;
      }
      dp[i][len] = 0;
      for (j = 0; j < 26; j++) {
        int x = last[i][j];
        if (x != -1) {
          dp[i][len] += dp[x][len - 1];
        }
      }
    }
  }
  f[0] = 1;
  for (i = 0; i < 26; i++) {
    if (last[n][i] != -1) {
      for (int len = 1; len <= n; len++) {
        f[len] += dp[last[n][i]][len];
      }
    }
  }
  bool foo = false;
  for (int len = n; len >= 0; len--) {
    if (k - f[len] <= 0) {
      cost += 1LL * k * (n - len);
      foo = true;
      break;
    } else {
      cost += 1LL * f[len] * (n - len);
      k -= f[len];
    }
  }
  if (foo)
    cout << cost << "\n";
  else
    cout << "-1\n";
}
