import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; public class Main { public static long mod_pow(long n, long m, long MOD){ if(m == 0){ return 1; } if(m == 1){ return n % MOD; } if(m % 2 != 0){ return (mod_pow(n, m - 1, MOD) * n) % MOD; }else{ final long ret = mod_pow(n, m / 2, MOD); return (ret * ret) % MOD; } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); final long MOD = 129402307; char[] N_ch = sc.next().toCharArray(); final boolean N_is_zero = N_ch.length == 1 && N_ch[0] == '0'; char[] M_ch = sc.next().toCharArray(); final boolean M_is_zero = M_ch.length == 1 && M_ch[0] == '0'; long N_mod = 0, M_mod = 0; for(final char c : N_ch){ N_mod *= 10; N_mod += Character.getNumericValue(c); N_mod %= MOD; } for(final char c : M_ch){ M_mod *= 10; M_mod += Character.getNumericValue(c); M_mod %= (MOD - 1); } //System.out.println(N_mod + " " + M_mod); if(N_mod == 0 && M_is_zero){ System.out.println(1); } else if(N_mod == 0){ System.out.println(0); } else if(N_mod == 1){ System.out.println(1); } else{ System.out.println(mod_pow(N_mod, M_mod, MOD)); } } }