#include<stdio.h>
int main()
{
	int a = 0;
	int arr[12] = { 0 };
	scanf("%d", &a);
	int i = 0;
	while (a)
	{
		arr[i] = a % 6;
		a /= 6;
		i++;
	}
	for (int j = i - 1; j >= 0; j--)
	{
		printf("%d", arr[j]);
	}
	return 0;
}