mod = 129402307 def calc_mod(n, mod): res = 0 d = 1 for s in n: res *= 10 res += int(s) res %= mod return res N = calc_mod(input(), mod) M = calc_mod(input(), mod - 1) print(pow(N, M, mod))