#include<cstdio>
#include<iostream>
using namespace std;

int main(void) 
{
	int a, b[] = { 0,1,2,3,5,7,8,9 };
	while (cin >> a)
	{
		if (a == 0)break;
		long long e = 1, ans = 0;
		while (a != 0)
		{
			int c = a % 8;
			ans += e * b[c];
			e *= 10;
			a /= 8;
		}
		cout << ans << endl;
	}
	return 0;
}