#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)


static const string t = "01235789";

string	 to(int n){
	string ans;
	while(n) ans += t[n%8] , n/=8;
	reverse(ans.begin(),ans.end());
	return ans;
}

int main(){
	int n;
	while(cin >> n , n){
		cout << to(n) << endl;
	}
}