#include<bits/stdc++.h>
using namespace std;

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

void solve(int x) {
  if( x/8 > 0 ) solve( x/8 );
  cout << change[x%8];
}

int main()
{
  int n;
  while( cin >> n, n ) {
    solve( n );
    cout << endl;
  }
}