a = int(input())
b = int(input())


mod = 129402307

print(pow(a,b,mod))