#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define clear(v) memset(v,0,sizeof(v))

int table[8] = { 0, 1, 2, 3, 5, 7, 8, 9 };

void oct(int n){
	if (n >= 8){
		oct(n / 8);
	}
	cout << table[n % 8];
}

int main(){
	int n;
	while (cin >> n, n){
		oct(n);
		cout << endl;
	}
}