#include<cstdio>
#include<vector>
#include<algorithm>
#include<sstream>
#include<string>
#include<iostream>
using namespace std;
string conv(int n){
    stringstream ss;
    while(n){
        ss<<n%8;
        n/=8;
    }
    string ret=ss.str();
    reverse(ret.begin(),ret.end());
    return ret;
}
const int l[]={0,1,2,3,5,7,8,9};
int main(){
    int n;
    while(cin>>n,n){
        string str=conv(n);
        for(int i=0;i<str.length();i++){
            cout<<l[str[i]-'0'];
        }
        cout<<endl;
    }
    return 0;
}