#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<int> buf;
		while(n)
		{
			buf.push_back(n % 8);
			n /= 8;
		}
		reverse(buf.begin(), buf.end());
		for(int i = 0; i < buf.size(); ++i)
		{
			cout << data[buf[i]];
		}
		cout << endl;
	}
}

int main()
{
	solve();
	return(0);
}