#include <iostream>
using namespace std;

typedef long long int LLI;

int n;

bool input() {
  cin >> n;
  if (!n) {
    return false;
  }
  return true;
}

void solve() {
  LLI b = 1;
  LLI k = 0;
  while (n) {
    int m = n % 8;
    if (m < 4) {
      k += m * b;
    } else if (m < 5) {
      k += (m + 1) * b;
    } else {
      k += (m + 2) * b;
    }
    n /= 8;
    b *= 10;
  }
  cout << k << endl;
}

int main() {
  while (input()) {
    solve();
  }
  return 0;
}