#include <iostream>
#include <set>
#include <map>
using namespace std;

int getValue(int x){
	if(x <= 3)
		return x;
	else if(x == 4)
		return 5;
	else
		return x + 2;
	
		
}
int main() {
	long long n;
	while(cin >> n && n){
		int ans[100] = {0}, c = 0;
		while(n > 0){
			ans[c++] = getValue(n % 8);
			n /= 8;
		}
		for(int i = c - 1; i >= 0; --i)
			cout << ans[i];
		cout << endl;
	}
	return 0;
}