'''No.2007 Arbitrary Mod (Easy) ''' a, n = map(int, input().split()) M = 10 ** 7 print(a ** n % M)