#include<iostream>
using namespace std;
int bajinzhi(int n){
	int sum=0,p=1;
	while(n>0){
		int t=n%8;
		sum=sum+t*p;
		p=p*10;
		n=n/8;
	}
	return sum;
} 
int main(){
	int n;
	while(scanf("%d",&n)!=EOF){
		int s=bajinzhi(n);
		printf("%d\n",s);
	}
}