#include<iostream>

using namespace std;

int main(){
  int n;
  long long ans, d;
  int list[] = {0,1,2,3,5,7,8,9};
  while(cin >> n, n){
    ans=0, d=1;
    while(n!=0){
      ans += d*list[n%8];
      d*=10;
      n/=8;
    }
    cout << ans << endl;
  }
}