#include <iostream>
using namespace std;

#define N 100
int main(){
	int n;
	while (cin >>n){
		int i = 0;
		int a[N] = {-1,-1,-1,-1,-1,-1};	//定义数组存每一位
		//把得到的每一位存在a数组中(这里是倒序存的)
		while (n){
			a[i++] = n%8;
			n/=8;
			
		}
		//将a中倒序的每一位,转成正序,成为一个数,存在result
		int result = 0,p=1;
		for (i=0;a[i]!=-1;i++){
			result = result + a[i]*p;
			p*=10;
		}
			
		cout <<result<<endl;
	}
	
}