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