N = int(input())
M = int(input())

ans = []
while M:
    M, mod = divmod(M, N)
    ans.append(mod)
if not ans:
    ans = [0]
print("".join(map(str, reversed(ans))))