#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wsign-compare"
using namespace std;
void ECHO(string _s) {
  cout << endl;
  (void)_s;
}
template <typename T, typename... Args>
void ECHO(string _s, T x, Args... args) {
  unsigned _i;
  string _s2 = "";
  for (_i = 0; _i < _s.length(); ++_i) {
    if (_s[_i] == ',') break;
    if (_s[_i] != ' ') _s2 += _s[_i];
  }
  if (_i == _s.length()) {
    --_i;
  }
  cout << "  (" << _s2 << "):" << x;
  ECHO(_s.substr(_i + 1, _s.length() - _i - 1), args...);
}
template <typename T0, typename T1>
inline ostream& operator<<(ostream& os, pair<T0, T1>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
inline ostream& operator<<(ostream& os, vector<T>& v) {
  for (unsigned i = 0; i < v.size(); ++i) cout << v[i] << "_";
  return os;
}
template <typename T>
inline T _min(T x1, T x2, T x3) {
  return min(x1, min(x2, x3));
}
template <typename T>
inline T _min(T x1, T x2, T x3, T x4) {
  return min(min(x1, x2), min(x2, x3));
}
inline int _gcd(int a, int b) {
  while (b) b %= a ^= b ^= a ^= b;
  return a;
}
const long long MAX_L = 110;
long long dp[MAX_L][MAX_L];
long long nxt[277][MAX_L];
long long n, k;
string s;
void fill_dp() {
  long long i, j, prev;
  for (i = 'a'; i <= 'z'; ++i) {
    prev = n;
    for (j = n - 1; j >= 0; --j) {
      nxt[i][j] = prev;
      if ((int)s[j] == i) {
        nxt[i][j] = prev;
        prev = j;
      } else
        nxt[i][j] = prev;
    }
  }
  dp[0][0] = 1;
  vector<int> used(26);
  fill((used).begin(), (used).end(), 0);
  dp[n - 1][1] = 1;
  used[s[n - 1] - 'a'] = 1;
  for (i = n - 2; i >= 0; --i) {
    dp[i][1] = dp[i + 1][1];
    if (!used[s[i] - 'a']) {
      dp[i][1]++;
      used[s[i] - 'a'] = 1;
    }
  }
  vector<int> last(26);
  for (j = 2; j <= n; ++j) {
    for (i = n - j; i >= 0; --i) {
      dp[i][j] = dp[i + 1][j];
      dp[i][j] += dp[i + 1][j - 1];
      dp[i][j] -= dp[nxt[(int)s[i]][i] + 1][j - 1];
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  long long i, j, cont = 0, money = 0, cost = 0;
  cin >> n >> k >> s;
  fill_dp();
  for (i = n; i >= 0; --i) {
    if (cont + dp[0][i] >= k) {
      cout << money + cost * (k - cont) << endl;
      exit(0);
    }
    cont += dp[0][i];
    money += dp[0][i] * cost;
    ++cost;
  }
  cout << -1 << endl;
  return 0;
}
