#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
constexpr long long MOD = 1000000007LL;
template <class T, class U>
inline bool chmax(T &a, U b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T, class U>
inline bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
long long dp[101][101];
vector<vector<int> > calcNext(const string &S) {
  int n = (int)S.size();
  vector<vector<int> > res(n + 1, vector<int>(26, n));
  for (int i = n - 1; i >= 0; --i) {
    for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
    res[i][S[i] - 'a'] = i;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  auto nex = calcNext(S);
  dp[0][0] = 1;
  for (int i = 0; i < (N); ++i) {
    for (int j = 0; j < (N); ++j) {
      for (int k = 0; k < (26); ++k) {
        if (nex[i][k] >= N) continue;
        dp[nex[i][k] + 1][j + 1] += dp[i][j];
      }
    }
  }
  long long ans = 0;
  for (int j = N; j >= 0; j--) {
    for (int i = 0; i < (N + 1); ++i) {
      if (K <= dp[i][j]) {
        ans += K * (N - j);
        K = 0;
        break;
      } else {
        K -= dp[i][j];
        ans += dp[i][j] * (N - j);
      }
    }
  }
  cout << (K ? -1 : ans) << '\n';
}
