#include <iostream>
#include <cstdio>
using namespace std;

int main(){
	long long n;
	while(cin >> n && n){
		char s[100] = {};
		char table[] = "01235789";
		sprintf(s,"%o",n);
		int i = 0;
		while(s[i]){
			putchar(table[s[i]-'0']);
			i++;
		}
		
		putchar('\n');
	}
}