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