#include <bits/stdc++.h>
using namespace std;
void setIO(const string &name = "") {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  if (name.length()) {
    freopen((name + ".in").c_str(), "r", stdin);
    freopen((name + ".out").c_str(), "w", stdout);
  }
}
template <typename T>
void read(vector<T> &a) {
  for (auto &x : a) cin >> x;
}
template <typename T>
void read(vector<T> &a, long long n) {
  a.resize(n);
  for (auto &x : a) cin >> x;
}
template <class T, class U>
ostream &operator<<(ostream &out, const pair<T, U> &v) {
  out << "(";
  out << v.first << "," << v.second;
  return out << ")";
}
template <class T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  for (auto(i) = 0; (i) < ((long long)(v).size()); (i)++) {
    if (i) out << ", ";
    out << v[i];
  }
  return out << "]";
}
template <typename T>
void print(vector<T> &a) {
  for (const auto &x : a) cout << x << ' ';
  cout << '\n';
}
void MOD(long long &x, long long m = 1000000007) {
  x %= m;
  if (x < 0) x += m;
}
template <typename T>
void dbg(const char *name, T &&arg1) {
  cout << name << " : " << arg1 << '\n';
}
template <typename T, typename... U>
void dbg(const char *names, T &&arg1, U &&...args) {
  const char *comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  dbg(comma + 1, args...);
}
template <class T>
void read(T &x) {
  cin >> x;
}
template <class T, class... U>
void read(T &t, U &...u) {
  read(t);
  read(u...);
}
long long gcd(long long a, long long b) { return !a ? b : gcd(b % a, a); }
long long n, k;
string s;
long long ans = 0;
vector<vector<long long> > pos;
vector<long long> cnt;
long long bin(long long ch, long long p) {
  long long lo = 0, hi = (long long)(pos[ch]).size() - 1;
  long long res = -1;
  while (lo <= hi) {
    long long mid = (lo + hi) / 2;
    if (pos[ch][mid] > p) {
      res = mid;
      hi = mid - 1;
    } else {
      lo = mid + 1;
    }
  }
  return res;
}
void f(long long len, long long ptr) {
  cnt[len]++;
  for (auto(i) = 0; (i) < (26); (i)++) {
    long long p = bin(i, ptr);
    if (p == -1) continue;
    f(len + 1, pos[i][p]);
  }
}
long long dp[105][105];
long long g(long long len, long long ptr) {
  if (len == 0) return 1;
  if (ptr != -1 and dp[len][ptr] != -1) return dp[len][ptr];
  long long res = 0;
  for (auto(i) = 0; (i) < (26); (i)++) {
    long long p = bin(i, ptr);
    if (p == -1) continue;
    res += g(len - 1, pos[i][p]);
    if (res >= k) res = k;
  }
  if (ptr != -1) dp[len][ptr] = res;
  return res;
}
void solve() {
  for (auto(i) = 0; (i) < (n + 1); (i)++) {
    cnt[i] += g(i, -1);
  }
}
int32_t main() {
  setIO();
  read(n, k, s);
  pos.resize(26);
  cnt.assign(n + 1, 0);
  for (auto(i) = 0; (i) < (n); (i)++) {
    pos[s[i] - 'a'].emplace_back(i);
  }
  memset(dp, -1, sizeof dp);
  solve();
  if (accumulate((cnt).begin(), (cnt).end(), 0LL) < k) {
    cout << "-1\n";
    return 0;
  }
  long long left = k;
  long long pt = n;
  while (left > 0) {
    if (cnt[pt] <= left) {
      ans += cnt[pt] * (n - pt);
      left -= cnt[pt];
      pt--;
    } else {
      ans += left * (n - pt);
      break;
    }
  }
  cout << ans << '\n';
  return 0;
}
