N = int(input()) M = int(input()) MOD = 129402307 N %= MOD print(pow(N, M, MOD))