#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+8
#define EPS 1e-8
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = (j); i < (k); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
int main(){
	int n;
	while(scanf("%d",&n),n){
		char ch[]="01235789";
		string ans = "";
		int cnt=0;
		while(n!=0){
			ans+=ch[n%8];
			n/=8;
		}
		reverse(ans.begin(),ans.end());
		cout << ans << endl;
	}
	return 0;
}