# -*- coding: utf-8 -*- N = int(input()) answer = '' while N>0: digit = str(N%7) answer = digit + answer N //= 7 print(answer)