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 nm = (x+y) / 3L
	
	def cmb(n: Long, k: Long): BigInt = {
		val M = BigInt(1000000007)
		val a = (BigInt(n-k+1) to BigInt(n)).reduce(_ * _ % M)
		(BigInt(2) to BigInt(k)).foldLeft(a)((l, r) => l * r.modInverse(M) % M)
	}
	
	pw.println(if ((x + y) % 3L != 0L || 2*y < x || 2*x < y) BigInt(0) else cmb(nm, x-nm))
	pw.flush()
}