#include <iostream>
using namespace std;

const int num[] = {0, 1, 2, 3, 5, 7, 8, 9};

int main()
{
  int n;
  
  while (cin >> n, n){
    long long ct = 0, d = 1;
    while (n > 0){
      ct += num[n % 8] * d;
      d *= 10;
      n /= 8;
    }
    cout << ct << endl;
  }
  return (0);
}