def solve(): N = int(input()) M = int(input()) num = 129402307 print( pow(N,M,num) ) solve()