
object Main extends App {
  import scala.io.StdIn._
  val mod = 1000000007L
  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val exp = Array.tabulate(n){_ ⇒ 1L}
  for (i ← exp.indices.tail) exp(i) = (exp(i - 1) * 2) % mod
  println((0 until n).map(count).sum % mod)
  def count(left: Int): Long = {
    if (left == 0) exp(n - m)
    else if (left + m > n) 0
    else (exp(left - 1) * exp(n - m - left)) % mod
  }
}
