import scala.math._
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 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 = solve1(X, Y)
    val result = count % (pow(10, 9).toInt + 7)
    print(result)
  }
}