#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<char, int>P;

char buf[11];
int main(){
	int n;
	while (scanf("%d", &n), n) {
		sprintf(buf, "%o", n);
		rep(i, strlen(buf)) {
			if (buf[i] >= '5')buf[i]++;
			if (buf[i] == '4')buf[i]++;
		}
		printf("%s\n", buf);
	}
	return 0;
}