N=int(input()) M=int(input()) r=[] while(True): r.append(str(M%N)) M//=N if M==0: break print("".join(reversed(r)))