mod = 129402307 n = int(input()) % mod m = int(input()) % (mod - 1) print(pow(n, m, mod) if n != 0 else 0)