#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>

#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)

using namespace std;

int main(void) {
	int c[8] = { 0,1,2,3,5,7,8,9 };
	int n;
	vector<int> v;
	while (cin >> n && n > 0) {
		v.clear();
		while (n > 0) {
			v.push_back(c[n % 8]);
			n /= 8;
		}
		for (int i = v.size() - 1; i >= 0; i--) {
			cout << v[i];
		}
		cout << endl;
	}
	
				  
	return 0;
}