fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. Scanner in = new Scanner (System.in);
  10. int n = in.nextInt();
  11. int k = 0;
  12. while(n > 0) {
  13. k += n%3 + 1;
  14. n /= 3;
  15. }
  16. System.out.print(k - 2);
  17. }
  18. }
Success #stdin #stdout 0.1s 35244KB
stdin
1447
stdout
16