import java.io.{BufferedReader, InputStreamReader}

object Main {
  val mod: Long = 1000000000 + 7

  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val Array(x, y) = in.readLine().split("\\s+").map(_.toInt)

    System.out.println(
      if (2 * x - y < 0 || (2 * x - y) % 3 != 0 || 2 * y - x < 0 || (2 * y - x) % 3 != 0 || (x + y) % 3 != 0) {
        0
      } else {
        comb((x + y) / 3, (2 * x - y) / 3)
      }
    )
  }

  def comb(n: Long, k: Long): Long = {
    if (n - k > k) {
      comb(n, n - k)
    } else {
      val fn = (2L to n).foldLeft(1L)((cur, i) => mmod(cur, i))
      val invfn = inv(fn)

      val invfk = (n to (k + 1) by -1).foldLeft(invfn)((cur, i) => mmod(cur, i))
      val invfnmk = (k to (n - k + 1) by -1).foldLeft(invfk)((cur, i) => mmod(cur, i))

      mmod(mmod(fn, invfk), invfnmk)
    }
  }

  def inv(n: Long): Long = pow(n, mod - 2)

  def pow(n: Long, p: Long): Long = {
    if (p == 0) {
      1
    } else if (p == 1) {
      n
    } else if (p % 2 == 0) {
      pow(mmod(n, n), p / 2)
    } else {
      mmod(n, pow(n, p - 1))
    }
  }

  @inline
  def mmod(a: Long, b: Long): Long = {
    a * b % mod
  }
}
