import std.stdio;
import std.conv;
import std.string;

int main()
{
    string oct1="01234567"c;
    string oct2="01235789"c;
    char[] buf;
    while (stdin.readln(buf)!='0'){
    int num;
    num=to!int(buf);
    int octnum=octal!(num);
	writeln(replace(toStringz(octnum),oct1,oct2));
}
    return 0;
}