#include <iostream>
#include <cstdlib>
#include <cstdio>

using namespace std;

int main(void)
{
	// itoa
	int n;
	while (cin >> n, n){
		char s[20];
		sprintf(s, "%o", n);
		
		string str = s;
		for (int i = 0; i < str.length(); i++){
			if ('4' <= str[i]) str[i]++;
			if ('6' <= str[i]) str[i]++;
		}
		cout << str << endl;
	}
	
	return 0;
}