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_lst=Base(M,N) if not ans_lst: ans_lst.append(0) print(*ans_lst[::-1],sep="")