import java.util.*; public class Main { static final int MOD = 129402307; public static void main (String[] args) { Scanner sc = new Scanner(System.in); char[] narr = sc.next().toCharArray(); long n = 0; for (char c : narr) { n *= 10; n += c - '0'; n %= MOD; } if (n == 0) { System.out.println(0); return; } char[] marr = sc.next().toCharArray(); long m = 0; for (char c : marr) { m *= 10; m += c - '0'; m %= MOD - 1; } System.out.println(pow(n, m)); } static long pow(long x, long p) { if (p == 0) { return 1; } else if (p % 2 == 0) { return pow(x * x % MOD, p / 2); } else { return pow(x, p - 1) * x % MOD; } } }