import scala.math._
import scala.util.control.TailCalls._
object Main {
  def solve1(x: Int, y: Int): Int = {
    (x, y) match {
      case (0, 0) =>
        1
      case (x, y) if x < 0 || y < 0 =>
        0
      case _ =>
        val m = solve1(x - 1, y - 2)
        val n = solve1(x - 2, y - 1)
        m + n
    }
  }
  def solve2(x: Int, y: Int): Int = {
    val memo = scala.collection.mutable.Map.empty[(Int, Int), Int]
    def go(x: Int, y: Int): Int = {
      memo.get((x, y)) match {
        case Some(v) =>
          v
        case None =>
          (x, y) match {
            case (0, 0) =>
              memo((0, 0)) = 1; 1
            case (x, y) if x < 0 || y < 0 =>
              0
            case _ =>
              val r = go(x - 1, y - 2) + go(x - 2, y - 1)
              memo((x, y)) = r; r
          }
      }
    }
    go(x, y)
  }

  def solve3(x: Int, y: Int): Int = {
    val memo = scala.collection.mutable.Map.empty[(Int, Int), Int]
    def go(x: Int, y: Int): TailRec[Int] = {
      memo.get((x, y)) match {
        case Some(v) =>
          done(v)
        case None =>
          (x, y) match {
            case (0, 0) =>
              memo((0, 0)) = 1; done(1)
            case (x, y) if x < 0 || y < 0 =>
              done(0)
            case _ =>
              for(m <- tailcall(go(x - 1, y - 2)); n <- tailcall(go(x - 2, y - 1)))
                yield {
                  memo((x, y)) = m + n
                  m + n
                }
          }
      }
    }
    go(x, y).result
  }

  def main(args: Array[String]): Unit = {
    val line = Console.in.readLine()
    val Array(tx, ty) = line.split(" ")
    val X = tx.toInt
    val Y = ty.toInt
    val count = solve3(X, Y)
    val result = count % (pow(10, 9).toInt + 7)
    print(result)
  }
}