n=int(input()) m=int(input()) if m==0: print(0) exit() ans=[] while m: ans.append(str(m%n)) m//=n ans=ans[::-1] print("".join(ans))