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

//対応表

//8進数変換
void eight(int n){
	int table[] = {0,1,2,3,5,7,8,9};
	if(n >= 8){
		eight(n / 8);
	}
	cout << table[n % 8];
}

int main(){
	int num;
	while(cin >> num,num){
		eight(num);
		cout << endl;
	}
	return 0;
}