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