import scala.io.StdIn._
object Main extends App {
  val Array(x, y) = readLine.split(" ").map(_.toInt)
  val Mod = 1000000007L
  if ((x + y) % 3 != 0) {
    println(0)
  } else if (x * 2 < y || y * 2 < x) {
    println(0)
  } else {
    val n = (x + y) / 3
    val k = x - n + 1

    def p(i: Long, div: Long, to: Long, t: Long = 1): Long = {
      if (div == to) t
      else p(i - 1, div + 1, to, t * i / div % Mod)
    }
    println(p(n, 1, k))
  }
}