fork download
  1. import java.io.BufferedReader;
  2. import java.io.InputStreamReader;
  3.  
  4. class Main
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
  9. String p = bufferedReader.readLine();
  10. long s=0;
  11. long[] x= {0,0,0,0,0,0,0,0,0,0};
  12. for(int i = 0; i < p.length(); i++) {
  13. char n = p.charAt(i);
  14. if(n =='0') x[0]++;
  15. else if(n =='1') x[1]++;
  16. else if(n =='2') x[2]++;
  17. else if(n =='3') x[3]++;
  18. else if(n =='4') x[4]++;
  19. else if(n =='5') x[5]++;
  20. else if(n =='6') x[6]++;
  21. else if(n =='7') x[7]++;
  22. else if(n =='8') x[8]++;
  23. else if(n =='9') x[9]++;
  24. }
  25. for(int i = 0; i < 10; i++)
  26. if (x[i]>1) s+=x[i]/2;
  27. System.out.print(s);
  28. }
  29. }
Success #stdin #stdout 0.05s 2184192KB
stdin
8 7 7 5 4 3 5 4 8
stdout
4