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