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

string tenToEight(int t) {
  string res = "";
  while(t >= 8) {
    res += (char)(t%8+'0');
    t /= 8;
  }
  res += (char)(t+'0');
  reverse(res.begin(),res.end());
  return res;
}

int main() {
  int n;
  string conv = "01235789";
  while(cin >> n && n) {
    string eight = tenToEight(n);
    for(int i = 0; i < eight.size(); ++i) cout << conv[eight[i]-'0'];
    cout << endl;
  }
  return 0;
}