import java.math.*;import java.util.*;public class big {public static void main(String... args){Scanner scan = new Scanner(System.in);System.out.println(new BigInteger(scan.next()).modPow(new BigInteger(scan.next()), BigInteger.valueOf(129402307)));}}