def modpow(n: str, m: str, mod: int) -> int: """巨大数 n, m の n^m % mod を求める (mod は素数)""" def modulo(s: str, m: int) -> int: """s % m を求める (s は巨大なので文字列)""" x = 0 for c in map(int, s): x = (10*x + c) % m return x if m == '0': return 1 a = modulo(n, mod) if a == 0: return 0 b = modulo(m, mod-1) return pow(a, b, mod) import sys sys.set_int_max_str_digits(0) def modulo(s: str, m: int) -> int: x = 0 for c in map(int, s): x = (10*x + c) % m return x MOD = 129402307 N = input() M = input() n = modulo(N, MOD) ans = pow(n, int(M), MOD) print(ans)