#include <bits/stdc++.h>
using namespace std;
long long lst[101][101];
long long dp[101][101];
int main() {
  {
    ios ::sync_with_stdio(false);
    cin.tie(0);
  };
  ;
  long long i, j, k, m, n, p, q, cnt, sum, c;
  cin >> n >> k;
  string s;
  cin >> s;
  memset(lst, -1, sizeof(lst));
  char ch;
  lst[0][s[0] - 'a'] = 0;
  for (j = 0; j < 26; j++) {
    for (i = 1; i < n; i++) {
      if (s[i] - 'a' == j)
        lst[i][j] = i;
      else
        lst[i][j] = lst[i - 1][j];
    }
  }
  memset(dp, 0, sizeof(dp));
  for (i = 0; i < n; i++) dp[i][1] = 1;
  for (j = 2; j <= n; j++) {
    for (i = 1; i < n; i++) {
      sum = 0;
      for (c = 0; c < 26; c++) {
        if (lst[i - 1][c] != -1) {
          sum += dp[lst[i - 1][c]][j - 1];
        }
      }
      dp[i][j] = sum;
    }
  }
  cnt = 0;
  long long cost = 0;
  for (j = n; j >= 1; j--) {
    sum = 0;
    for (c = 0; c < 26; c++) {
      if (lst[n - 1][c] == -1)
        continue;
      else {
        sum += dp[lst[n - 1][c]][j];
      }
    }
    if (sum >= k) {
      cost += k * (n - j);
      cout << cost << "\n";
      return 0;
    } else {
      cost += sum * (n - j);
      k -= sum;
    }
  }
  if (k == 1) {
    cost += n;
    cout << cost << "\n";
  } else if (k > 1) {
    cout << "-1\n";
  }
}
