#include <iostream>
using namespace std;
int  main(){
  char s[]={'0','1','2','3','5','7','8','9'};
  long long int n;
  for(;cin>>n,n;)
    {
      string a="";
      for(;n>0;n/=8)
	a=s[n%8]+a;
      cout<<a<<endl;
    }
}