#*+++++++++++++++++++++
# * Written By --------
# * Boddapati Mahesh  **
# * IIIT Hyderabad *****
# */

import sys 
x=map(int,raw_input().split())
l=[]
for i in range(0,len(x)):
        if(x[i]!=-1):
            while(x[i]!=0):
                l.append(x[i]%7)
                x[i]/=7
        for j in range(len(l)-1,-1,-1):
            sys.stdout.write(str(l[j]))
        l=[]
        if(i!=len(x)-1):
            sys.stdout.write(" ")
print