#include<iostream>
using namespace std;

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

void solve(int n){
	if(n >= 8){
		solve(n/8);
	}
	cout << table[n%8];
}



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