#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long m, n;
long long dp[110][110], t[110][26];
char s[110];
int main() {
  cin >> n >> m;
  scanf("%s", s + 1);
  int l = strlen(s + 1);
  for (int i = 1; i <= n; i++) {
    dp[i][1] = 1LL;
    for (int j = i - 1; j >= 1; j--)
      if (!t[i][s[j] - 'a']) {
        for (int k = 1; k <= j; k++) {
          dp[i][k + 1] = dp[i][k + 1] + dp[j][k];
          if (dp[i][k + 1] > 1e12) dp[i][k + 1] = 1e12;
        }
        t[i][s[j] - 'a'] = 1;
      }
  }
  long long sum = 0;
  for (int k = 0; k <= n - 1; k++)
    for (int i = 0; i < 26; i++)
      for (int j = n; j >= 1; j--)
        if (s[j] == i + 'a') {
          if (m > dp[j][n - k]) {
            sum = sum + 1LL * k * dp[j][n - k];
            m -= dp[j][n - k];
          } else {
            sum = sum + 1LL * k * m;
            m = 0;
          }
          break;
        }
  if (m > 0) {
    sum += n;
    m--;
  }
  if (m > 0)
    printf("-1\n");
  else
    printf("%lld\n", sum);
}
