#include <bits/stdc++.h>
using namespace std;
inline int nextint() {
  int x;
  scanf("%d", &x);
  return x;
}
inline long long nextll() {
  long long x;
  scanf("%lld", &x);
  return x;
}
template <typename T>
void scanint(T& x) {
  T c = getchar();
  while (((c < 48) || (c > 57)) && (c != '-')) c = getchar();
  bool neg = false;
  if (c == '-') {
    neg = true;
    c = getchar();
  }
  x = 0;
  for (; c < 48 || c > 57; c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) x = (x * 10) + (c - 48);
  if (neg) x = -x;
}
template <typename T>
T min_(T a, T b) {
  return a > b ? b : a;
}
template <typename T, typename... Ts>
T min_(T first, Ts... last) {
  return min_(first, min_(last...));
}
template <typename T>
T max_(T a, T b) {
  return a > b ? a : b;
}
template <typename T, typename... Ts>
T max_(T first, Ts... last) {
  return max_(first, max_(last...));
}
template <class T, class S>
std::ostream& operator<<(std::ostream& os, const std::pair<T, S>& t) {
  os << "(" << t.first << ", " << t.second << ")";
  return os;
}
template <typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last) out << ", ";
  }
  out << "]";
  return out;
}
template <typename T>
ostream& operator<<(ostream& out, const set<T>& v) {
  out << "{";
  auto last = v.end();
  for (auto i = v.begin(); i != last;) {
    out << *i;
    if (++i != last) out << ", ";
  }
  out << "}";
  return out;
}
template <typename T>
ostream& operator<<(ostream& out, const multiset<T>& v) {
  out << "{";
  auto last = v.end();
  for (auto i = v.begin(); i != last;) {
    out << *i;
    if (++i != last) out << ", ";
  }
  out << "}";
  return out;
}
template <typename T, typename VAL>
ostream& operator<<(ostream& out, const map<T, VAL>& v) {
  out << "{";
  auto last = v.end();
  for (auto i = v.begin(); i != last;) {
    out << *i;
    if (++i != last) out << ", ";
  }
  out << "}";
  return out;
}
template <class T, class S>
void outvp(vector<pair<T, S>>& v) {
  for (pair<T, S> x : v) cout << x.first << " " << x.second << endl;
}
template <typename T>
void outv(vector<T>& v) {
  for (T x : v) cout << x << " ";
  cout << endl;
}
template <typename T>
void outs(set<T>& v) {
  for (T x : v) cout << x << " ";
  cout << endl;
}
template <typename T>
void outm(map<T, int>& v, int n = 1) {
  for (T& x : v) cout << (n == 1 ? x.first : x.second) << " ";
  cout << endl;
}
template <typename Arg, typename... Args>
void ptrace(std::ostream& out, Arg&& arg, Args&&... args) {
  out << "<< ";
  out << std::forward<Arg>(arg);
  using expander = int[];
  (void)expander{0, (void(out << ", " << std::forward<Args>(args)), 0)...};
  out << " >>\n";
}
template <typename Arg, typename... Args>
void trace(Arg&& arg, Args&&... args) {}
template <typename T>
void readv(vector<T>& v, int n) {
  v = vector<T>(n);
  for (int i = 0; i < (int)(n); i++) cin >> (v[i]);
}
template <typename T>
void reads(set<T>& v, int n) {
  T x;
  for (int i = 0; i < (int)(n); i++) {
    cin >> x;
    v.insert(x);
  }
}
template <typename T>
void readm(map<T, int>& v, int n) {
  T x;
  for (int i = 0; i < (int)(n); i++) {
    cin >> x;
    v[x]++;
  }
}
template <typename Arg, typename... Args>
void read(Arg&& arg, Args&&... args) {
  cin >> std::forward<Arg>(arg);
  using expander = int[];
  (void)expander{0, (void(cin >> std::forward<Args>(args)), 0)...};
}
long long pwr(long long base, long long p, long long mod) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = (ans * base) % mod;
    base = (base * base) % mod;
    p /= 2;
  }
  return ans;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
const long double PI = (long double)(3.1415926535897932384626433832795);
const long long mx_ll = numeric_limits<long long>::max();
const int mx_int = numeric_limits<int>::max();
const int mod = 1e9 + 7;
const int oo = 0x3f3f3f3f;
const long long OO = 0x3f3f3f3f3f3f3f3fll;
const double eps = 1e-9;
const int dx[8] = {0, 1, 0, -1, -1, 1, -1, 1};
const int dy[8] = {1, 0, -1, 0, -1, 1, 1, -1};
const int dsx[4] = {0, 1, 0, -1};
const int dsy[4] = {1, 0, -1, 0};
const int maxn = 200123;
void _build() {}
template <typename T>
void finalize(T x) {
  cout << x << endl;
  exit(0);
}
void _solve() {
  int n;
  long long k;
  string s;
  read(n, k, s);
  if (k == 1) finalize(0LL);
  vector<vector<int>> lst(n, vector<int>(26, -1));
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(26); j++) {
      if (i) lst[i][j] = lst[i - 1][j];
    }
    lst[i][s[i] - 'a'] = i;
  }
  vector<vector<long long>> dp(n, vector<long long>(n, 0));
  for (int i = 0; i < (int)(n); i++) {
    dp[i][1] = 1;
  }
  for (int len = 2; len < (int)(n); len++) {
    for (int i = 1; i < (int)(n); i++) {
      long long sum = 0;
      for (int c = 0; c < (int)(26); c++) {
        if (lst[i - 1][c] != -1) sum += max(0LL, dp[lst[i - 1][c]][len - 1]);
        sum = (sum) < (k) ? (sum) : (k);
      }
      dp[i][len] = sum;
    }
  }
  long long cost = 0;
  k--;
  for (int len = n - 1; len >= (int)(1); len--) {
    long long sum = 0;
    for (int c = 0; c < (int)(26); c++) {
      if (lst[n - 1][c] != -1) sum += dp[lst[n - 1][c]][len];
    }
    sum = (sum) < (k) ? (sum) : (k);
    cost += (n - len) * sum;
    k -= sum;
    if (k == 0) finalize(cost);
  }
  if (k == 1) finalize(cost + n);
  cout << -1 << endl;
}
void _input() {}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  bool GOOGLE = false;
  _build();
  int qq = 1;
  if (GOOGLE) cin >> qq;
  for (int i = 0; i < (int)(qq); i++) {
    _input();
    if (GOOGLE) cout << "Case #" << i + 1 << ": ";
    _solve();
  }
}
