# AOJ 0208 Room Numbers of a Hospital

# Python3 2018.6.23 bal4u

# 8進数に変換して、01234567を01235789に置き換える



dic = {'0':'0','1':'1','2':'2','3':'3','4':'5','5':'7','6':'8','7':'9'}

while 1:

	n = int(input())

	if n == 0: break

	s = list(format(n, 'o'))

	for i in range(len(s)): s[i] = dic[s[i]]

	print(*s, sep='') 



# AOJ 0208 Room Numbers of a Hospital

# Python3 2018.6.23 bal4u

# 8進数に変換して、01234567を01235789に置き換える



dic = {'0':'0','1':'1','2':'2','3':'3','4':'5','5':'7','6':'8','7':'9'}

while 1:

	n = int(eval(input()))

	if n == 0: break

	s = format(n, 'o')

	ans = ''

	for i in range(len(s)): ans += dic[s[i]]

	print(ans) 



# AOJ 0208 Room Numbers of a Hospital
# Python3 2018.6.23 bal4u
# 8進数に変換して、01234567を01235789に置き換える
dic = {"0": "0", "1": "1", "2": "2", "3": "3", "4": "5", "5": "7", "6": "8", "7": "9"}
while 1:
    n = int(input())
    if n == 0:
        break
    s = list(format(n, "o"))
    for i in range(len(s)):
        s[i] = dic[s[i]]
    print(*s, sep="")

# AOJ 0208 Room Numbers of a Hospital
# Python3 2018.6.23 bal4u
# 8進数に変換して、01234567を01235789に置き換える
dic = {"0": "0", "1": "1", "2": "2", "3": "3", "4": "5", "5": "7", "6": "8", "7": "9"}
while 1:
    n = int(eval(input()))
    if n == 0:
        break
    s = format(n, "o")
    ans = ""
    for i in range(len(s)):
        ans += dic[s[i]]
    print(ans)

-    n = int(input()) +    n = int(eval(input())) -    s = list(format(n, "o")) +    s = format(n, "o") +    ans = "" -        s[i] = dic[s[i]] -    print(*s, sep="") +        ans += dic[s[i]] +    print(ans)