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