def Base(N,card): assert N>=0 assert card>=2 base=[] while N: base.append(N%card) N//=card return base N=int(input()) M=int(input()) ans=Base(M,N) print(*ans[::-1],sep="")