//32
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    char o[10];
    sprintf(o,"%o",n);
    for(int i=0;o[i];i++){
      cout<<char(o[i]+(o[i]>='4')+(o[i]>='5'));
    }
    cout<<endl;
  }
  return 0;
}