import math inputer = int(input()) result ="" sev_base = 12 while sev_base >=0: if int(math.pow(7,sev_base))<=inputer or inputer ==0: result =result+str(int(inputer/math.pow(7,sev_base))) inputer=inputer%math.pow(7,sev_base) sev_base=sev_base-1 print(result)