#include <iostream>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;

int main(){
	int n, num[] = {0,1,2,3,5,7,8,9};
	while(cin >> n, n) {
		long long a=0, d=1;
		while(n) {
			a += num[n%8]*d;
			d *= 10;
			n /= 8;
		}
		cout << a << endl;
	}
	return 0;
}