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

const string digit = "01235789";

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> v;
        int t = n;
        while (t) {
            v.push_back(t % 8);
            t /= 8;
        }
        string res = "";
        for (int i=0; i<(int)v.size(); ++i) {
            res = digit[v[i]] + res;
        }
        cout << res << endl;
    }
    return 0;
}