#include<iostream>
#include<vector>
using namespace std;
int t[] ={0,1,2,3,5,7,8,9};
vector<int> u;
int main(){
  int n;
  while(cin>>n&&n){
    u.clear();
    while(n>0){
      u.push_back(t[n%8]);
      n/=8;
    }
    for(int i=u.size()-1;i>=0;i--)cout<<u[i];
    cout<<endl;
  }
  return 0;
}