import scala.io.StdIn.readLine

object Main {

  def times(m:Long, n:Long, z:Long) =  ( (m%z) * (n%z) ) % z

  def pow(x:Long, y:Long, z:Long):Long = {
    def scan(m:Long, n:Long, odd:Long):Long =
      if(n==0) 1
      else if(n==1) times(m,odd,z)
      else scan(times(m,m,z), n/2, (if(n%2==1) times(odd, m, z) else odd))
    scan(x, y, 1)
  }

  def main(args: Array[String]) = {
    val n = readLine().split(" ").map(_.toLong)
    println(pow(n(0),n(1),1000000007))
  }
}