#include int main(void) { char s[16]="0123456"; long long x,n,f; scanf("%lld",&n); if(n == 0){printf("0\n");return 0;} x = 13841287201; f = 0; while(x != 0){ if(!((n/x) == 0 && f == 0)){ printf("%c",s[(n/x)]); f = 1; } n%=x; x/=7; } printf("\n"); return 0; }