# coding=utf-8
while True:
    try:
        n=int(input())
        my_list=[]
        while n>0:
            my_list.append(n%8)
            n=n//8
        while len(my_list)>0:
            print(my_list[-1],end='')
            my_list.pop()
        print()
    except:
        break
/**************************************************************
	Problem: 2142
	User: admin
	Language: Python
	Result: Accepted
	Time:150 ms
	Memory:34480 kb
****************************************************************/