//栈的实现
#include <iostream>
#include <stack>

using namespace std;
int main()
{
    int n;
    while(cin>>n){
        if(n==0){
            cout<<0<<endl;
        }
        stack<int> s;
        while(n!=0){
            s.push(n%8);
            n/=8;
        }
        while(!s.empty()){
            cout<<s.top();
            s.pop();
        }
        cout<<endl;
    }
    return 0;
}