n = input() m = input() mod = 129402307 # tmp = pow(n, m) # print tmp % mod print pow(n, m, mod);