import scala.collection.mutable.ArrayBuffer

object Main extends App {
	val sc = new java.util.Scanner(System.in)
	val pw = new java.io.PrintWriter(System.out)
	
	val x, y = sc.nextLong
	
	lazy val n = (2L * y - x) / 3L
	lazy val m = (2L * x - y) / 3L
	
	def cmb(n: Long, r: Long): Long = {
		val M = BigInt(1000000007)
		val k = math.min(n - r, r)
		val a = (BigInt(n-k+1) to BigInt(n)).reduce(_ * _ % M)
		(BigInt(1) to BigInt(k)).foldLeft(a)((l, r) => l * r.modInverse(M) % M).toLong
	}
	
	pw.println(
		if ((x + y) % 3L != 0L) 0L
		else if (n < 0L || m < 0L) 0L
		else cmb(n + m, n)
	)
	pw.flush()
}