b=int(input('hah')) f=0 h='' while b>0: f = b%3 b= b//3 if f==0: f=4 b=b-1 h=str(f)+h print(h) # if b==3 # b=4