N = int(input()) M = int(input()) ans = "" i = 0 while M >= N: M, r = divmod(M, N) ans += str(r) ans += str(M) print(ans[::-1])