N = int(input()) M = int(input()) li = [] while M != 0: a = M // N b = M % N li.append(b) M = a r = "" for i in li: r += str(i) print(r[::-1])