N = int(input()) M = int(input()) if M == 0: print(0) exit() ans = [] while M: ans.append(str(M%N)) M//=N print(''.join(reversed(ans)))