#include <bits/stdc++.h>
using namespace std;
long long n, k, dp[102][102], a[26], q, p;
string s;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> n >> k >> s;
  s = ' ' + s;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < 26; ++j) {
      if (a[j]) {
        for (int z = 2; z <= i; ++z) {
          dp[i][z] += dp[a[j]][z - 1];
          if (dp[i][z] >= k) dp[i][z] = k;
        }
      }
    }
    dp[i][1] = 1;
    a[s[i] - 'a'] = i;
  }
  dp[0][0] = 1;
  for (int i = 0; i < 26; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (a[i]) dp[0][j] += dp[a[i]][j];
    }
  }
  for (int i = n; i >= 0; --i) {
    if (q + dp[0][i] >= k) {
      p += (k - q) * (n - i);
      cout << p << endl;
      return 0;
    }
    q += dp[0][i];
    p += dp[0][i] * (n - i);
  }
  cout << -1 << endl;
  return 0;
}
