#include<iostream>
using namespace std;
int main(){
	int n,d[99]; while(cin>>n,n){
		int d[8]={0},c=0;
		while(n>0){
			d[c++]=n%8;
			n/=8;
		}
		while(c--)cout<<"01235789"[d[c]];cout<<endl;
	}
	return 0;
}