#include <iostream>
#include <cstdio>
using namespace std;

int d[]={0,1,2,3,5,7,8,9};

void solve(int n){
  if(8<=n){
    solve(n/8);
  }
  cout<<d[n%8];
  return;
}

int main(void){
  int  n;
  while(cin>>n&&n!=0){
    solve(n);
    cout<<endl;
  }
  return 0;
}