N=int(input()) M=int(input()) X=[] while M: X.append(M%N) M//=N print(*X[::-1],sep="")