A,B,c=int(input()),int(input()),"" while B:c+=str(B%A);B//=A; print([c[::-1],0][c==""])