fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main() {
  4. int t;
  5. cin>>t;
  6. while(t--)
  7. {
  8. int n,c;
  9. cin>>n>>c;
  10. string s;
  11. cin>>s;
  12. map<char,int> m;
  13. for(auto x : s)
  14. {
  15. m[x]++;
  16. }
  17. int a=m.size();
  18. if(a>c)
  19. {
  20. cout<<0<<"\n";
  21. }
  22. else
  23. {
  24. cout<<c-a<<"\n";
  25. }
  26. }
  27. return 0;
  28. }
Success #stdin #stdout 0s 5528KB
stdin
4
10 5
aabbccddef
4 4
aaaa
6 6
abcdef
8 5
cbacbbac
stdout
0
3
0
2