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

void convert(int x, vector<int> *v) {
  if(x == 0) return;
  convert(x / 8, v);
  v->push_back(x % 8);
}

int main() {
  while(1) {
    int n;
    cin >> n;
    if(n == 0) break;

    vector<int> v;
    convert(n, &v);
    for(int i = 0; i < v.size(); i++) {
      int temp = v[i];
      if(temp >= 4) temp++;
      if(temp >= 6) temp++;
      cout << temp;
    }
    cout << endl;
  }
  return 0;
}