MOD = 129402307 MOD2 = MOD-1 n = int(input())%MOD m = int(input())%MOD2+MOD2 print(pow(n,m,MOD))