#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

long long int n;
int num[8]={0,1,2,3,5,7,8,9};

int main(void){
	while(1){
		scanf("%lld",&n);
		if(n==0)break;
		string str;
		while(n>0){
			int s=num[n%8];
			str+=s+'0';
			n=n/8;
		}
		reverse(str.begin(),str.end());
		cout << str << endl;
	}
    return 0;
}