while 4:

    n=int(eval(input()))

    if n==0:break

    print((oct(n)[2:].translate(str.maketrans("4567","5789"))))
from sys import stdin

for i in stdin:

    if i=="0\n":break

    print((oct(int(i))[2:].translate(str.maketrans("4567","5789"))))
while 4:
    n = int(eval(input()))
    if n == 0:
        break
    print((oct(n)[2:].translate(str.maketrans("4567", "5789"))))

from sys import stdin

for i in stdin:
    if i == "0\n":
        break
    print((oct(int(i))[2:].translate(str.maketrans("4567", "5789"))))

-while 4: -    n = int(eval(input())) -    if n == 0: +from sys import stdin + +for i in stdin: +    if i == "0\n": -    print((oct(n)[2:].translate(str.maketrans("4567", "5789")))) +    print((oct(int(i))[2:].translate(str.maketrans("4567", "5789"))))