#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	int table[] = { 0,1,2,3,5,7,8,9 };
	unsigned long long n;
	while (cin >> n, n) {
		vector<int>out;
		while (n > 0) {
			out.push_back(table[n % 8]);
			n /= 8;
		}
		for (int i = out.size() - 1; i >= 0; i--)cout << out[i];
		cout << endl;
	}
	return 0;
}