#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
int table[] = {0,1,2,3,5,7,8,9};

int main(){
  ll n;

  while(cin >> n,n){
    ll e = 1,ans = 0;
    while(1){
      int m = n%8;
      ans += e*table[m];
      e *= 10;
      n /= 8;
      if(n == 0)break;
    }
    cout << ans << endl;
  }
}