import java.util.*; import java.io.*; public class Main { static final int MOD = 129402307; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); char[] nArr = br.readLine().toCharArray(); char[] mArr = br.readLine().toCharArray(); long n = 0; for (char c : nArr) { n *= 10; n += c - '0'; n %= MOD; } int length = mArr.length; long[] values = new long[length]; values[0] = n; for (int i = 1; i < length; i++) { values[i] = 1; for (int j = 0; j < 10; j++) { values[i] *= values[i - 1]; values[i] %= MOD; } } long ans = 1; for (int i = 0; i < length; i++) { int x = mArr[length - 1 - i] - '0'; long tmp = 1; for (int j = 0; j < x; j++) { tmp *= values[i]; tmp %= MOD; } ans *= tmp; ans %= MOD; } System.out.println(ans); } }