#include<iostream>

using namespace std;

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

string solve(int n) {
  if (n == 0) return "";
  int k = n % 8;
  return solve(n / 8) + "01235789"[k];
}

int main() {
  int n;
  while (true) {
    cin >> n;
    if (n == 0) break;
    cout << solve(n) << endl;
  }
  return 0;
}