#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int num;
int data[8] = {0,1,2,3,5,7,8,9};
vector<int> make(){
  vector<int> out;
  while(num){
    out.push_back(num%8);
    num/=8;
  }
  reverse(out.begin(),out.end());
  return out;
}

int main(){
  while(cin >> num && num){
    vector<int> V = make();
    for(int i = 0; i < V.size(); i++) cout << data[V[i]];
    cout << endl;
  }
  return 0;
}