def pow(m, n, mod)
  return 1 if n == 0
  
  if n.even?
    return pow(m * m % mod, n / 2, mod)
  else
    return m * pow(m, n - 1, mod) % mod
  end
end
m, n = gets.split.map(&:to_i)
puts pow(m, n, 1_000_000_007)