#include <bits/stdc++.h>
using namespace std;
const long long N = 1e2 + 10, M = 26;
long long n, k, last[M], ans[N], dp[N][N];
string s, t;
long long sum(long long a, long long b) { return min(k + 10, a + b); }
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  memset(last, -1, sizeof last);
  cin >> n >> k >> t;
  s += '0';
  for (char c : t) s += c;
  dp[0][0] = 1;
  for (long long i = 1; i <= n; i++) {
    dp[i][1] = 1;
    for (long long j = 2; j <= i; j++)
      for (long long z = 0; z < M; z++)
        if (last[z] != -1) dp[i][j] = sum(dp[i][j], dp[last[z]][j - 1]);
    last[s[i] - 'a'] = i;
  }
  for (long long i = 0; i < M; i++)
    for (long long j = 1; j <= n; j++)
      if (last[i] != -1) ans[j] = sum(ans[j], dp[last[i]][j]);
  ans[0] = 1;
  long long res = 0;
  for (long long i = n; i >= 0; i--)
    if (ans[i] >= k)
      return cout << res + k * (n - i) << endl, 0;
    else
      res += ans[i] * (n - i), k -= ans[i];
  cout << -1 << endl;
}
