#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n;
    while(cin>>n){
        vector<int> a;
        while(n>0){
            a.push_back(n%8);
            n/=8;
        }
        for(int i=a.size()-1;i>=0;i--) cout<<a[i];
        cout<<endl;
    }
}