#include <iostream>

using namespace std;

int ch[] = {0, 1, 2, 3, 5, 7, 8, 9};

void dfs(long long n) 
{
    if (n >= 8)
        dfs(n / 8);
    cout << ch[n % 8];
}

int main()
{
    long long n;

    while (cin >> n, n) {
        dfs(n);
        cout << endl;
    }

    return 0;
}