n = int(input()) m = int(input()) MOD = 129402307 print(pow(n,m,MOD))