#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
  const char tbl[] = { '0','1','2','3','5','7','8','9' };
  for(;;){
    long long n;
    cin >> n;
    if(n==0) break;
    char buf[20];
    sprintf(buf,"%o",n);
    for(int i=0; i<20; i++){
      if(buf[i] == '\0') break;
      buf[i] = tbl[buf[i] - '0'];
    }
    cout << buf << endl;
  }
  return 0;
}