#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

int main()
{
    long long n;
    while(cin >> n && n)
    {
        string ans = "";
        int rest;
        while(n)
        {
            rest = (int)(n % 8);

            if(rest==0) ans = "0" + ans;
            if(rest==1) ans = "1" + ans;
            if(rest==2) ans = "2" + ans;
            if(rest==3) ans = "3" + ans;
            if(rest==4) ans = "5" + ans;
            if(rest==5) ans = "7" + ans;
            if(rest==6) ans = "8" + ans;
            if(rest==7) ans = "9" + ans;

            n /= 8;
        }
        cout << ans << endl;

    }
    return 0;
}