#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

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

// 10?????°x???b?????°?????????
vector<ll> decimalConvert(ll x, ll b, int keta = 64) {
	vector<ll> res;
	while (x) {
		res.push_back(x % b);
		x /= b;
	}
	while (res.size() < keta) res.push_back(0);
	reverse(ALL(res));
	
	return res;
}


int main() {
	int n;
	while (cin >> n, n) {
		vector<ll> v = decimalConvert(n, 8, 20);
		
		string ans = "";
		REP(i, v.size()) ans += conv[v[i]] + '0';
		
		int z = 0;
		while (z < ans.size() && ans[z] == '0') z++;
		if (z == ans.size()) ans = "0";
		else ans = ans.substr(z);
		
		cout << ans << endl;
	}
	return 0;
}