#include <bits/stdc++.h>
using namespace std;
const long long MAX = 101;
long long inf = 1000000000000001, mod = 998244353, z = 0;
long long dp[27][MAX], n, k;
string s;
int main() {
  cin >> n >> k;
  dp[0][0] = 1;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    for (int j = n; j >= 1; j--) {
      long long cnt = 0;
      for (int z = 0; z < 27; z++) cnt += dp[z][j - 1];
      dp[s[i] - 96][j] = cnt;
    }
  }
  long long cnt = 0, ans = 0;
  for (int j = n; j >= 1; j--) {
    for (int i = 1; i < 27; i++) {
      long long pl = min(k - cnt, dp[i][j]);
      cnt += pl;
      ans += (n - j) * pl;
      if (ans == -388) {
        cout << "old";
      }
      if (cnt == k) {
        cout << ans;
        return 0;
      }
    }
  }
  if (k - cnt == 1) {
    cout << ans + n << '\n';
  } else {
    cout << -1 << '\n';
  }
  return 0;
}
