#include<iostream>
#include<vector>
using namespace std;

int convert(int n){
	static int c[8]={0,1,2,3,5,7,8,9};
	return c[n];
}
int main(){
	int n;
	vector<int> v;
	vector<int>::reverse_iterator i;
	while(cin>>n,n){
		v.clear();
		while(n){
			v.push_back(convert(n%8));
			n/=8;
		}
		for(i=v.rbegin();i!=v.rend();++i)
			cout<<*i;
		cout<<endl;
	}
}