ll inp(){ char c =getchar(); while(c < '0' || c > '9') c = getchar(); ll sum = 0; while(c >= '0' && c <= '9'){ sum = sum * 10 + c - '0'; c = getchar(); } return sum; }
ll f[200][200]; bool used[30]; char s[200];
intmain(){ int n = inp(); ll k = inp(); scanf("%s", s + 1); for(int i = 0; i <= n; i++) f[i][1] = 1; for(int len = 2; len <= n + 1; len++){ for(int i = 0; i <= n; i++){ memset(used, false, sizeof(used)); for(int j = i + 1; j <= n; j++) if(!used[s[j] - 'a']){ used[s[j] - 'a'] = true; f[i][len] += f[j][len - 1]; f[i][len] = std::min(f[i][len], k); } } } ll ans = 0; for(int i = n; i >= 0; i--){ ll sum = f[0][i + 1]; memset(used, false, sizeof(used)); if(k > sum){ k -= sum; ans += (n - i) * sum; } else { ans += (n - i) * k; k = 0; } } if(k > 0){ printf("-1\n"); return0; } printf("%lld\n", ans); }