#include <stdio.h>
const int a[8] = { 0, 1, 2, 3, 5, 7, 8, 9 };
int n;
int main() {
	while(true) {
		scanf("%d", &n);
		if(n == 0) break;
		bool flag = false;
		while(n != 0) {
			int val = n / 8;
			flag = flag || val;
			if(flag) {
				printf("%d", a[val]);
			}
			n /= 8;
		}
		printf("\n");
	}
	return 0;
}