import java.io.PrintWriter

object Scanner {
  private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0
  @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
  @inline private def hasNextByte(): Boolean =
    if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }
  @inline private def hasNext(): Boolean = {
    while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
    hasNextByte()
  }
  @inline private def readByte(): Byte =
    if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }
  def next(): String = {
    if(!hasNext()) ???
    val sb = new StringBuilder; var b = readByte()
    while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
    sb.toString
  }
  def nextInt(): Int = {
    val n = nextLong()
    if (n < Int.MinValue || Int.MaxValue < n) ???
    n.toInt
  }
  def nextLong(): Long = {
    if(!hasNext()) ???
    var minus = false; var b = readByte()
    if (b == '-') { minus = true; b = readByte() }
    def go (b: Byte, n: Long = 0): Long =
      if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }
      else if (minus) { -n } else { n }
    go(b)
  }
  def nextDouble(): Double = next.toDouble
}

object OutPut {
  def print(f:PrintWriter => Unit): Unit = {
    val pw: PrintWriter = new java.io.PrintWriter(System.out)
    //pw.println("")
    f(pw)
    pw.flush()
  }
}
object MyDataFormat {
  def double(x: Double, precision: Int): String = {
    var num = x
    val sb = new StringBuilder
    if (num < 0) {
      sb.append("-")
      num = -num
    }
    num += Math.pow(10, -precision) / 2
    sb.append(num.toLong)
    sb.append(".")
    num -= num.toLong
    (0 until precision).foreach(i => {
      num *= 10
      sb.append(num.toInt)
      num -= num.toInt
    })
    sb.toString
  }

  def array2(arr: scala.collection.mutable.ArrayBuffer[scala.collection.mutable.ArrayBuffer[Int]], x: Int, y: Int): Option[Int] = {
    try { Some(arr(x)(y)) } catch {
      case _: Exception => None
    }
  }
}

object Loop {
  @inline def rep(n: Int, f: => Unit): Unit = { var c = 0; while (c < n) { f; c += 1 } }
  @inline def rep(n: Int, f: Int => Unit): Unit = { var c = 0; while (c < n) { f(c); c += 1 } }

  @inline def breakAble(n: Int, m: Int, f: Int => Boolean): Unit = if (f(n) && n < m) breakAble(n + 1, m, f)
  @inline def !(n: Int): Int = (1 + n) * n / 2
}

object Search {
  def find(data: Array[Int], key: Int): Option[Int] = {
    val res = java.util.Arrays.binarySearch(data, key)
    if (res >= 0) Some(res) else None
  }
}

object WarshallFloyd {
  def run(n: Int, vectorMap: Array[Array[Int]]): Array[Array[Int]] = {
    Loop.rep(n, k => {
      Loop.rep(n, i => {
        Loop.rep(n, j => {
          val a = vectorMap(i)(j)

          val b = vectorMap(i)(k)
          val c = vectorMap(k)(j)
          val distance = Math.min(a, b + c)
          vectorMap(i)(j) = distance
        })
      })
    })
    vectorMap
  }
}

case class CumulativeSum(arr: Array[Int]) {
  val n = arr.length
  val sumArray: Array[Int] = Array.fill[Int](n + 1)(0)
  Loop.rep(n, i => sumArray(i + 1) = sumArray(i) + arr(i))

  //TODO 半開区間に変更
  //座標指定 上限下限共に含む
  def countByCoordinate(start: Int, end: Int): Int =
    countBySubscript(start - 1, end - 1)

  //添字指定 上限下限共に含む
  def countBySubscript(start: Int, end: Int): Int = {
    if (start <= end) sumArray(end + 1) - sumArray(start)
    else sumArray(start + 1) - sumArray(end)
  }
}

case class UnionFind(n: Int) {
  //添字が固有ID、値が親IDを表す
  val arr: Array[Int] = Array.tabulate[Int](n)(identity)
  def findParent(v: Int): Int = {
    val parent = arr(v)
    if (v == parent) parent else findParent(parent)
  }
  def registerParent(child: Int, parent: Int): Unit = {
    val oldParent = arr(child)
    arr(oldParent) = parent
  }
}

object PrimeNumbers {
  def isPrimeNumber(n: Int): Boolean = ???
  def createUntil(n: Int): Array[Int] = {
    val arr: Array[Int] = Array.empty
    //i = 2からスタートしたいので全体をずらす
    Loop.rep(n - 2, i => {
      //自身より小さい全ての素数で割り切れなければ、素数
      if (!arr.exists(v => i % v == 0)) {
        //append
      }
    })
    arr
  }
}



object Main extends App {
  val x, y = Scanner.nextInt()
  val mod = 1000000007

  def check(x: Int, y: Int): Option[(Int, Int)] = {
    val a = 2 * x - y
    val b = 2 * y - x
    if (a >= 0 && b >= 0 && a % 3 == 0 && b % 3 == 0) Some((a/3, b/3)) else None
  }

  def resolve(a: Int, b: Int): Long = {
    var molecule: Long = 1
    var denominator: Long = 1
    Loop.rep(a, i => {
      val newMolecule: Long = (molecule * (b + i + 1)) % mod
      val newDenominator: Long = (denominator * (i + 1)) % mod
      molecule = newMolecule
      denominator = newDenominator
    })
    var result = 0
    Loop.breakAble(1, 1000000000, i => {
      if ((denominator * (i + 1)) % mod == molecule) {
        result = i + 1; false
      } else true
    })
    result
  }

  val result = check(x, y).map(ab => resolve(ab._1, ab._2))
  println(result.getOrElse(0))
}