#include <iostream>
using namespace std;

int main(){
  int x;

  while(cin >> x, x){
    string ans = "";

    while(x != 0){
      int rem = x % 8;
      x /= 8;

      int d;

      if(rem < 4){
        d = rem;
      }
      else if(rem < 5){
        d = rem + 1;
      }
      else{
        d = rem + 2;
      }

      ans = (char)('0' + d) + ans;
    }

    cout << ans << endl;
  }
}