#include <stdio.h> int main() { long n=0,sum=0,t=1; scanf("%d",&n); while(n>0) { sum=sum+n%6*t; n/=6; t*=10; } printf("%ld",sum); return 0; }