N=int(raw_input()) M=int(raw_input()) ans=1 mul=N mod=129402307 while M>0: if M%2==1: ans*=mul ans%=mod mul*=mul mul%=mod M/=2 print ans