m, n = gets.split.map(&:to_i)
a = 1000000007
def comp_mod_exp(b, e, m)
  return 1 if e == 0
  ans = comp_mod_exp(b, e / 2, m)
  ans = (ans * ans) % m
  ans = (ans * b) % m if e % 2 == 1
  return ans
end
puts comp_mod_exp(m, n, a)
