fork download
  1. import java.util.Scanner;
  2.  
  3. public class Main
  4. {
  5. public static void main (String[] args)
  6. {
  7. long n;
  8. int differentDigitsCount = 0;
  9. int[] digitsCount = new int[10];
  10. Scanner scanner = new Scanner(System.in);
  11.  
  12. n = scanner.nextLong();
  13.  
  14. while (n!=0)
  15. {
  16. digitsCount[(int)(n%10)]++;
  17. n/=10;
  18. }
  19. for (int i = 0; i < 10; i++)
  20. {
  21. if (digitsCount[i] > 0) differentDigitsCount++;
  22. }
  23.  
  24. System.out.println(differentDigitsCount);
  25. }
  26. }
Success #stdin #stdout 0.08s 4386816KB
stdin
1
stdout
1