fork(2) download
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define pii pair<int,int>
  6. #define ll long long
  7. #define N (int)(1e5+10)
  8. #define mod 1000000007
  9. #define mp make_pair
  10. #define pb push_back
  11. #define nd second
  12. #define st first
  13. #define inf mod
  14. #define endl '\n'
  15. #define sag (sol|1)
  16. #define sol (root<<1)
  17. #define ort ((bas+son)>>1)
  18. #define bit(x,y) ((x>>y)&1)
  19.  
  20. int main(){
  21. int H[500]={0};
  22. int t=0,i,n;
  23. char str[N];
  24.  
  25. cin >> n;
  26.  
  27. scanf("%s",str);
  28.  
  29. for(i=0 ; i<n ; i++)
  30. t += (H[str[i]]++) == 0;
  31.  
  32. if(n > 26)
  33. puts("-1");
  34. else
  35. cout << n - t << endl;
  36. }
  37.  
Success #stdin #stdout 0s 3440KB
stdin
4
keko
stdout
1