#include <iostream>
using namespace std;
typedef long long ll;
int main( void )
{
  ll a;
  while( 1 ){
    cin >> a;
    if( !a ) break;
    ll ret = 0;
    ll scale = 1;
    while( a > 0 ){
      ll d = a & 7;
      a = a >> 3;
      if( d >= 4 ) d++;
      if( d >= 6 ) d++;
      ret += d * scale;
      scale *= 10;
    }
    cout << ret << endl;
  }
  return 0;
}