#include <bits/stdc++.h>
using namespace std;
class Solution {
 public:
  long long solve(string &s, long long k) {
    int n = s.size();
    vector<vector<int>> g(n, vector<int>(26, -1));
    g[n - 1][s[n - 1] - 'a'] = n - 1;
    for (int i = n - 2; i >= 0; --i) {
      int ci = s[i] - 'a';
      for (int c = 0; c < 26; ++c) {
        if (ci == c) {
          g[i][c] = i;
        } else {
          g[i][c] = g[i + 1][c];
        }
      }
    }
    vector<vector<long long>> f(n + 1, vector<long long>(n + 1, 0));
    for (int i = 0; i <= n; ++i) {
      f[i][0] = 1;
    }
    for (int i = n - 1; i >= 0; --i) {
      for (int l = 1; l <= n - i; ++l) {
        for (int c = 0; c < 26; ++c) {
          int k = g[i][c];
          if (k == -1) continue;
          f[i][l] += f[k + 1][l - 1];
        }
      }
    }
    long long cost = 0;
    int l = n;
    while (k > 0 && l >= 0) {
      cost += (n - l) * min(k, f[0][l]);
      k -= f[0][l];
      l--;
    }
    if (k > 0) return -1;
    return cost;
  }
};
int main() {
  Solution sol;
  int n;
  long long k;
  cin >> n >> k;
  string s;
  cin >> s;
  cout << sol.solve(s, k) << endl;
  return 0;
}
