#yuki499 def f(n,m): s="" while n>0: a=n%m s+=str(a) n/=m return s[::-1] n=int(raw_input()) if n==0: print 0 else: print f(n,7)