#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[1000001];//動的計画法
int prime[1000001];
int main(){
    int table[]={0,1,2,3,5,7,8,9};
    int num,keta,ans[100];
    while(cin>>num,num){
        keta=0;
        while(num>0){
            ans[keta++]=table[num%8];
            num/=8;
        }
        for(int i=keta-1;i>=0;i--) cout<<ans[i];
        cout<<endl;
    }
    return 0;
}
