#include <cstdio>
#include <vector>

using namespace std;

int main(){
	int self;
	char str[256];
	char* pt;
	bool flag;
	while(1){
		scanf("%d",&self);
		if(self == 0){break;}
		sprintf(str,"%o",self);
		//printf("%s\n",str);
		//01234567
		//01235789
		for(pt = str;*pt!='\0';pt++){
			if(*pt >= '5'){
				*pt += 2;
			}else if(*pt >= '4'){
				*pt += 1;
			}
		}
		printf("%s\n",str);
	}
	return 0;
}