#include<iostream>
#include<stack>
using namespace std;
stack<int>s;
int main(){
int n;
while(scanf("%d",&n)!=EOF){
if(n==0) printf("0");
while(n!=0){
s.push(n%8);
n=n/8;
}
while(!s.empty()){
printf("%d",s.top());
s.pop();
}
printf("\n");
}
return 0;
}