• Source
    1. import java.util.*;
    2. import java.lang.*;
    3. import java.io.*;
    4.  
    5. class Main
    6. {
    7. public static void main (String[] args) throws java.lang.Exception
    8. {
    9. long x, x1, x2;
    10. long c;
    11. int k = 0;
    12. Scanner sc = new Scanner(System.in);
    13. x = sc.nextInt();
    14. boolean f = false;
    15. while(!f){
    16. x1 = x;
    17. x2 = 0;
    18. while (x1 > 0)
    19. {
    20. c = x1%10;
    21. x1 /= 10;
    22. x2 = x2*10 + c;
    23. }
    24. if (x == x2)
    25. {
    26. System.out.format("%d", k);
    27. f = true;
    28. break;
    29. }
    30. else {
    31. x += x2;
    32. k++;
    33. }
    34. }
    35. }
    36. }