#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n, n) {
    string s = "";
    while (n) {
      s = to_string(n % 8) + s;
      n /= 8;
    }
    string ans = "";
    for (int i = 0; i < int(s.size()); i++) {
      if (s[i] <= '3') ans += s[i];
      else if (s[i] <= '4') ans += s[i] + 1;
      else ans += s[i] + 2;
    }
    cout << ans << endl;
  }  

  return 0;
}
