#include<iostream>
#include<cmath>
using namespace std;
int x[8] = { 0,1,2,3,5,7,8,9 };
int n, ok, k;
int main() {
	while (true) {
		ok = 0;
		cin >> n;
		if (!n) { break; }
		for (int i = 10; i >= 0; i--) {
			k = (n / (int)pow(8, i)) % 8;
			if (k > 0) { ok = 1; }
			if (ok == 1) { cout << x[k]; }
		}
		cout << endl;
	}
}