#include <cstdio>
#include <cstdlib>
#include <cstring>

const int table[] = { 0, 1, 2, 3, 5, 7, 8, 9 };

int main(){
	while(true){
		int n;
		scanf("%d", &n);
		if(n == 0){ break; }
		long long answer = 0, e = 1;
		while(n != 0){
			int m = n % 8;
			answer += e * table[m];
			e *= 10;
			n /= 8;
		}
		printf("%lld\n", answer);
	}
	return 0;
}