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

int main() {
    string conv = "01235789";
    int N;
    while(cin >> N, N) {
        string ret = "";
        for(; N>0; N/=8) {
            ret += conv[N%8];
        }
        reverse(ret.begin(), ret.end());
        cout << ret << endl;
    }
}
