// 2011/08/09 Tazoe

#include <iostream>
using namespace std;

void radix(int n)
{
	if(n==0)
		return;

	radix(n/8);

	switch(n%8){
		case 0:
			cout << 0;
			break;
		case 1:
			cout << 1;
			break;
		case 2:
			cout << 2;
			break;
		case 3:
			cout << 3;
			break;
		case 4:
			cout << 5;
			break;
		case 5:
			cout << 7;
			break;
		case 6:
			cout << 8;
			break;
		case 7:
			cout << 9;
			break;
	}
}

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		radix(n);
		cout << endl;
	}

	return 0;
}