import std.stdio;
import std.string;

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