import sys a = int(input()) b = int(input()) MOD=129402307 a=a%MOD if a==0 : print(0) sys.exit() x=1 while(b): if b%2==1: x=x*a%MOD a=a*a%MOD b=int(b/2) print(x)