#include<iostream>
using namespace std;

int main(){
	char *hoge = "01235789";
	int kyu;
	int shinketa;
	char shin[10];
	
	while(cin>>kyu,kyu){
		shinketa=0;
		do{
			shin[shinketa]=hoge[kyu % 8];
			shinketa++;
			kyu /= 8;
		}while(kyu);
		while(shinketa--) cout<<shin[shinketa];
		cout<<endl;
	}
	
	return 0;
}