#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)

int main() {
  for (int n; cin >> n, n; ) {
      const string digit = "01235789";
      string ans;
      while (n) {
          ans = digit[n % 8] + ans;
          n /= 8;
      }
      cout << ans << endl;
  }
  return 0;
}