#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
  int n;
  while(cin>>n,n){
    char sc[20];
    sprintf(sc,"%o",n);
    string s1=string(sc);
    for(int i=0;i<s1.size();++i){
      char c=s1[i];
      if(c>='4')++c;
      if(c>='6')++c;
      cout<<c;
    }
    cout<<endl;
  }
  return 0;
}