#include<algorithm>
#include<iostream>
#include<string>

int main()
{
	const char* s = "01235789";
	int n;
	std::string ans;

	while( std::cin >> n, n )
	{
		ans.clear();

		while( n )
		{
			ans += s[n & 7];
			n >>= 3;
		}

		std::reverse( ans.begin(), ans.end() );
		std::cout << ans << std::endl;
	}

	return 0;
}