class Solution { public int solution(int n) { String snum=""; while(n>0){ snum+=n%3; n/=3; } return Integer.parseInt(snum,3); } }