#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
int main() {
  int P[8] = {0, 1, 2, 3, 5, 7, 8, 9};
  long long A;
  while (cin >> A, A) {
    long long q = 1, ans = 0;
    while (A != 0) {
      ans += q * P[A % 8];
      q *= 10;
      A /= 8;
    }
    cout << ans << endl;
  }
  return 0;
}