#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	int n;
	while(scanf("%d", &n), n){
		char str[16];
		sprintf(str, "%o", n);
		rep(i, strlen(str)){
			printf("%c", str[i] + (str[i]>='4') + (str[i]>='5'));
		}
		puts("");
	}
	
	return 0;
}