#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <map>
using namespace std;


int main() {
    stack<int> mystack;
    int n;
    while (scanf("%d", &n) != EOF) {
        //转为8进制
        while (n != 0) {
            int t = n % 8;
            mystack.push(t);
            n /= 8;
        }
        while (!mystack.empty()) {
            int t = mystack.top();
            mystack.pop();
            printf("%d", t);
        }
        printf("\n");
    }
}
// 64 位输出请用 printf("%lld")