import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val X, Y = in.next().toInt

  val MOD = 1e9.toInt + 7
  def repeatSquares(x: Long, n: Long): Long = {
    if(n == 0)
      1
    else if(n % 2 == 0)
      repeatSquares(x*x % MOD, n/2)
    else
      (x * repeatSquares(x*x % MOD, n/2)) % MOD
  }

  val b = ((2.0 / 3) * Y - (1.0 / 3) * X).round.toInt
  val w = ((2.0 / 3) * X - (1.0 / 3) * Y).round.toInt



  def fact(n: Int, res: Long): Long = {
    if (n == 1)
      res
    else {
      fact(n-1, (res * n) % MOD)
    }
  }

  var ba = 1L
  var wa = 1L

  def factInv(n: Int, res: Long): Unit = {
    if(n == 0)
      ()
    else {
      if (n == b)
        ba = res
      if (n == w)
        wa = res

      factInv(n-1, (res * n) % MOD)
    }
  }

  if (b + 2*w == X && 2*b + w == Y) {
    val mc = new ModComb(w+b, MOD)


    var ans: Long = fact(w+b, 1L)
    factInv(b+w, repeatSquares(ans, MOD-2))
    ans *= ba
    ans %= MOD
    ans *= wa
    ans %= MOD


    println(ans)
  }
  else {
    println(0)
  }
}

// class ModComb(maxNum: Int, mod: Long) {

  // private def repeatSquares(x: Long, n: Long): Long = {
  //   if(n == 0)
  //     1
  //   else if(n % 2 == 0)
  //     repeatSquares(x*x % mod, n/2)
  //   else
  //     (x * repeatSquares(x*x % mod, n/2)) % mod
  // }

//   val fact = new Array[Long](maxNum + 1)

//   fact(0) = 1
//   for (i <- 1 to maxNum)
//     fact(i) = (i * fact(i-1)) % mod

//   val factInv = new Array[Long](maxNum + 1)



//   // nCk
//   def comb(n: Int, k: Int): Long = {
//     val numer = fact(n)
//     val denom = (factInv(n-k) * factInv(k)) % mod

//     (numer * denom) % mod
//   }

// }


object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
