#include<iostream>
using namespace std ;

int N ;
int table[] = {0,1,2,3,5,7,8,9} ;

void Solve( int x ){
	if( x >= 8 ) Solve( x/8 ) ;
	cout << table[ x%8 ] ;
}

int main(){
	
	while( cin >> N , N ){
		Solve( N ) ;
		cout << endl ;
	}
	
	return 0 ;
}