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