#include<iostream>
using namespace std;

int main(void){
  int num[] = {1,2,3,5,6,7,8,9};
  int n;
  while(cin>>n,n){
    long long a=0,d=1;
    while(n){
      a+=num[n%8]*d;
      d*=10;
      n/=8;
    }	
    cout<<a<<endl;
  }
}