mod = 129402307 n = int(input()) % mod m = int(input()) print(pow(n, m, mod))