#include<iostream>
using namespace std;

int main()
 {
    int n;
    while(cin>>n,n)
    {
        int d[99]={0},c=0;
        while(n>0)
         {
            d[c++]=n%8;
            n/=8;
        }
        while(c--)
        cout<<"01235789"[d[c]]<<endl;
 
    }
    return 0;
}