#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 5;   const int maxm = 1e6 + 10;   const int mod = 1e9 + 7;   queue<string> que;   string str;   set<string> se;   int ans, n, k;   void bfs() {     if (k - 1 == 0) return;     que.push(str);     while (que.size()) {       string now = que.front();       que.pop();       for (int i = 0; i < now.size(); i++) {         string zz =   ;         for (int j = 0; j < now.size(); j++)           if (j != i) zz += now[j];         if (se.find(zz) == se.end()) {           se.insert(zz);           que.push(zz);           ans += (n - zz.size());           if (se.size() == k - 1) return;         }       }     }   }   int main() {     scanf( %d %d , &n, &k);     cin >> str;     bfs();     if (se.size() == k - 1)       printf( %d n , ans);     else       printf( -1 n );     return 0;   }   