#include<iostream>
using namespace std;
int box[]={0,1,2,3,5,7,8,9};
void oct(int x){
	int a=x%8;
	if(x/8!=0)
	oct(x/8);
	cout<<box[a];
}
int main(){
	int n;
	while(cin>>n,n){
		oct(n);
		cout<<endl;
	}
	return 0;
}