#include<stdio.h>
#define MAXSIZE 100
typedef int datatype;
typedef struct{
	datatype a[MAXSIZE];
	int top;
}sequence_stack;
void init(sequence_stack *st)
{
	st->top=0;
}
void push(sequence_stack *st,datatype x)
{
	if(st->top==MAXSIZE)
		printf("\nthe stack is full.");
	st->a[st->top]=x;
	st->top++;
}
void pop(sequence_stack *st)
{
	if(st->top==0)
		printf("\nthe stack is empty.");
	st->top--;
}
main()
{
	sequence_stack st;
	void init(st);
	int e;
	scanf("%d",&n);
	while(n)
	{
		push(&st,n%8);
		n=n/8;
	}
	while(!st->top)
	{
		e=pop(&st);
		printf("%d",e);
	}
}