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

typedef long long ll;

#define rep(i,a) for(int i=0;i<(a);++i)
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

const int MAX = 1000000000;
int n;
string table[] = {"0", "1", "2", "3", "5", "7", "8", "9"};

string rec(int c)
{
    int a, b;
    a = c / 8; b =c % 8;

    if(a  == 0) 
        return table[b];
    else 
        return rec(a) + table[b];
}

int main()
{
    while(cin >> n && n) 
        cout << rec(n) << endl;
}