#include <iostream>

using namespace std;

int main(){
  int newnum[8] = {0,1,2,3,5,7,8,9};
  long input_num;

  int count_num;
  while(cin >> input_num && input_num != 0){
    //    output_num = 0;
    count_num = 0;
  long output_num[13]={0};
    while(input_num != 0){
      output_num[count_num] = newnum[input_num % 8];
      input_num /= 8;
	    //input_num = (input_num-input_num % 8)/8;
      //      cout << output_num << " " ;
      count_num++;
    }
    /*
    for(int j=count_num-1;j>0;j--){
      output_num[j-1] += output_num[j] * 10;
      //      cout << output_num[j] << " ";
    }
    cout << output_num[0];
    */

    for(int j=count_num-1;j>=0;j--){
      cout << output_num[j] ;
    }
    

    cout << endl;
  }

}