def solve(): N=int(input()) M=int(input()) if M==0: return "0" X=[] while M>0: X.append(M%N) M//=N return "".join(map(str,X[::-1])) print(solve())