#include<stdio.h>
int table[]={0,1,2,3,5,7,8,9};
int output[100];
int now;
int main(){
	int a;
	while(scanf("%d",&a),a){
		now=0;
		while(a>0){
			output[now++]=table[a%8];
			a/=8;
		}
		for(int i=now-1;i>=0;i--)printf("%d",output[i]);
		printf("\n");
	}
}