#include int main(){ int N,A[18]={0},p=0; scanf("%d",&N); while(N>0){ A[p++]=N%7;N/=7; } while(p>0)printf("%d",A[--p]); printf("\n"); return 0; }