#include<iostream>
using namespace std;

void solve(int n){
	if(!n)
		return;
	solve(n/8);
	int tmp = n%8;
	switch(n%8){
		case 0:
		case 1:
		case 2:
		case 3:
			break;
		case 4:
			tmp++;
			break;
		default:
			tmp += 2;
	}
	cout << tmp;
}

int main(){
	int n;
	while(true){
		cin >> n;
		if(!n)
			return 0;
		solve(n);
		cout << endl;
	}
}