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

int main() {
    int a;
    while (cin >> a) { 
    vector<int>v;
       while(a!=0)
       {
            v.push_back(a%8);
            a = a/8;
       }
       for(int i = v.size()-1;i>=0;i--)
       {
        cout<<v[i];
       }cout<<endl;
    }
}
// 64 位输出请用 printf("%lld")