def CONVERT7(S): if S == 0: return "0" ANS = "" while S > 0: ANS += str(S % 7) S //= 7 return ANS[::-1] print(CONVERT7(int(input())))