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