object Main {
  def main(args: Array[String]): Unit = {
    val Array(m, n) = io.StdIn.readLine().split(" ").map(_.toInt)
    println(power(m, n))
  }

  def power(m: Int, n: Int): Int = {
    def loop(m: Int, n: Int, acc: Int): Int = n match {
      case 0 => acc
      case _ if n % 2 == 0 => loop(m * m, n / 2, acc)
      case _ => loop(m, n - 1, (acc * m) % 1000000007)
    }
    loop(m, n, 1)
  }
}