#include <stdio.h>

int main() {
	int n;
	while (scanf("%d",&n) != EOF) {
		int s[20],cnt=0,temp;
		while(n>0) {
			temp=n%8;
			s[cnt++]=temp;
			n/=8;
		}
		for(int i=cnt-1; i>=0; i--) {
			printf("%d",s[i]);
		}
		printf("\n");
	}
	return 0;
}