import java.util.*; public class Main { static final int MOD = 129402307; public static void main (String[] args) { Scanner sc = new Scanner(System.in); long n = 0; for (char c : sc.next().toCharArray()) { n *= 10; n += c - '0'; n %= MOD; } char[] arr = sc.next().toCharArray(); int length = arr.length; long[] bases = new long[length]; bases[length - 1] = n; long ans = pow(n, arr[length - 1] - '0'); for (int i = length - 2; i >= 0; i--) { bases[i] = pow(bases[i + 1], 10); ans *= pow(bases[i], arr[i] - '0'); ans %= MOD; } System.out.println(ans); } 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; } } }