N = list(map(int, list(input()))) M = list(map(int, list(input()))) mod = 129402307 n = 0 d = len(N) for i in range(d): n += N[i] * pow(10, d - i - 1, mod) % mod n %= mod m = 0 dd = len(M) for i in range(dd): m += M[i] * pow(10, dd - i - 1, mod - 1) % (mod - 1) m %= mod - 1 print(pow(n, m, mod))