n, m = int(input()), int(input()) ans = [] if m else ["0"] while m: ans.append(str(m%n)); m //= n print("".join(ans[::-1]))