#include <bits/stdc++.h>
using namespace std;
const int N = 111;
long long u[N][N];
int p[N];
int c[500];
int n;
long long k;
string second;
long long cost = 0;
int main() {
  memset(u, -1, sizeof u);
  memset(c, -1, sizeof c);
  memset(p, -1, sizeof p);
  cin >> n >> k >> second;
  for (int i = 0; i < n; i++) {
    p[i] = c[second[i]];
    c[second[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= n; j++) {
      if (p[i] == -1) {
        u[i][j] = 0;
        if (i > 0) u[i][j] += u[i - 1][j];
        if (j == 1) {
          u[i][j] += 1;
        } else if (i > 0) {
          u[i][j] += u[i - 1][j - 1];
        }
      } else {
        u[i][j] = 0;
        if (i > 0) u[i][j] += u[i - 1][j];
        if (i > 0 && j > 1) {
          u[i][j] += u[i - 1][j - 1];
          if (p[i] - 1 >= 0) {
            u[i][j] -= u[p[i] - 1][j - 1];
          }
        }
      }
    }
  }
  for (int i = n; i >= 1; i--) {
    if (k - u[n - 1][i] <= 0) {
      cost += k * (n - i);
      k = 0;
      break;
    } else {
      cost += u[n - 1][i] * (n - i);
      k -= u[n - 1][i];
    }
  }
  if (k == 1) {
    cout << cost + n << '\n';
    ;
  } else if (k > 1) {
    cout << -1 << '\n';
    ;
  } else {
    cout << cost << '\n';
    ;
  }
  return 0;
}
