# problem 1 P = 129402307 N=int(input()) M=int(input()) print(pow(N,M,P))