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): Long = {
    var x: Long = m
    var y = n
    var acc: Long = 1
    while(y != 0) {
      if (y % 2 == 0) {
        x = x * x % 1000000007
        y /= 2
      } else {
        y -= 1
        acc = (x * acc) % 1000000007
      }
    }
    acc
  }
}