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(); char[] M_ch = sc.next().toCharArray(); 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); System.out.println(mod_pow(N_mod, M_mod, MOD)); } }