#include <bits/stdc++.h>
#define INF (1<<29)
#define all(c) (c).begin(),(c).end()
#define pb(c) push_back(c)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int getv(int x){
  if(x == 4) return 5;
  return (x < 4) ? x : x+2;
}

void convert(int n){
  if(n == 0) return;
  convert( n/8 );
  cout << getv(n%8);
}

int main(){
  ios::sync_with_stdio(false);
  int n;

  while(cin >> n && n){
    convert(n);
    cout << endl;
  }


}