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

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