fork(1) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Main {
  6. public static void main (String[] args) {
  7. Scanner scan = new Scanner(System.in);
  8. int n = scan.nextInt();
  9. int i = 0;
  10. int j = 0;
  11. int num[] = new int[10];
  12. if (n == 0) {
  13. num[0] = 0;
  14. } else {
  15. while (n > 0) {
  16. num[j] = n % 10;
  17. n /= 10;
  18. j++;
  19. }
  20. j--;
  21. }
  22. int count = 0;
  23. while (i <= j) {
  24. if (num[i] == num[j]) count++;
  25. i++;
  26. j--;
  27. }
  28. System.out.print(count);
  29. }
  30. }
Success #stdin #stdout 0.16s 321344KB
stdin
1234567891
stdout
1