#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int a[] = {0,1,2,3,5,7,8,9};
void solve(int n){
  if(!n) return;
  solve(n/8);
  cout << a[n%8];
}
int main(void){
  int n;
  while(cin >> n && n){
    solve(n);
    cout << endl;
  }
}