func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long int inf = (long long int)1e18 + 10;   long long int dp[102][102] = {{0}};   map<char, long long int> m;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int n, k;     string s;     cin >> n >> k;     cin >> s;     m[s[0]] = 1;     dp[0][0] = 1;     dp[1][0] = 1;     dp[1][1] = 1;     for (long long int i = 2; i <= n; i++)       for (long long int j = 0; j <= i; j++) {         if (j <= i - 1) dp[i][j] = dp[i - 1][j];         if (j == 1) {           dp[i][1] += (m.find(s[i - 1]) == m.end());           m[s[i - 1]] = 1;         } else {           dp[i][j] += dp[i - 1][j - 1];           long long int r = -1;           for (long long int k = i - 2; k >= 0; k--) {             if (s[k] == s[i - 1]) {               r = k;               break;             }           }           if (r != -1) dp[i][j] -= dp[r][j - 1];         }       }     long long int ans = 0;     for (long long int i = n; i >= 0; i--) {       if (dp[n][i] >= k) {         ans += k * (n - i);         k = 0;         break;       } else {         ans += dp[n][i] * (n - i);         k -= dp[n][i];       }     }     if (k == 0) {       cout << ans <<   n ;     } else {       cout <<  -1 n ;     }   }   