#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair
int main(){
  long long n;
  while(cin>>n&&n){
    string ans="";
    while(n>0){
      ans+=n%8+'0';
      n/=8;
    }
    for(int i=ans.size()-1;i>=0;i--){
      if(ans[i]>='4')ans[i]++;
      if(ans[i]>='6')ans[i]++;
      cout<<ans[i];
    }
    cout<<endl;
  }
}