# -*- coding: utf-8 -*- ''' N=0のケースに注意! ''' N = int(input()) answer = '' if N==0: answer = '0' else: while N>0: digit = str(N%7) answer = digit + answer N //= 7 print(answer)