                                                            
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii;
typedef long long ll ;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()

int main(void){
  int no[] = {0,1,2,3,5,7,8,9};
  int num;
  while(cin>>num,num){
    vector<int> inp;
    while(num>0){
      inp.push_back(num%8);
      num/=8;
    }

    reverse(all(inp));

    rep(i,inp.size()){

      cout<<no[inp[i]];
    }
    cout<<endl;
  }
}