import java.math.BigInteger; import java.util.Scanner; public class Main{ static BigInteger mod=BigInteger.valueOf(129402307); static long pow(long a,long x,long m){ if(x==0) return 1; else if(x%2==0) return pow((a*a)%m,x/2,m)%m; else return (a*pow((a*a)%m,x/2,m))%m; } public static void main(String[] args){ Scanner sc=new Scanner(System.in); while(sc.hasNext()){ BigInteger n=sc.nextBigInteger(); BigInteger m=sc.nextBigInteger(); if(n.compareTo(BigInteger.ZERO)==0) System.out.println(0); else if(m.compareTo(BigInteger.ZERO)==0) System.out.println(1); else{ n=n.remainder(mod); m=m.remainder(mod.subtract(BigInteger.ONE)); long nn=n.longValue(),mm=m.longValue(); if(mm==0 && nn==0) System.out.println(0); else if(mm==0) System.out.println(1); else if(nn==0) System.out.println(0); else System.out.println(pow(nn,mm,mod.longValue())); } } } }