#include <cstdio>

using namespace std;

void conv(int t)
{
	char tbl[] = "01235789";
	bool flag = false;
	
	for (int i = 30; i >= 0; i -= 3){
		if (flag == true || (t >> i) & 7){
			flag = true;
			printf("%c", tbl[(t >> i) & 7]);
		}
	}
	
	printf("\n");
}

int main()
{
	int n;
	
	while (scanf("%d", &n) && n){
		conv(n);
	}
	
	return (0);
}