fun main(args: Array<String>) {
    val (X,Y) = readIntList()
    val mod = 1000000007
    val a = (2*X - Y)/3
    val b = (2*Y - X)/3
    
    if ((2*X - Y)%3 != 0 || a < 0 || b < 0){
        println(0)
        return
    }


    var comb = Comb(a+b, mod)

    val fact = (comb.fac[a+b]*comb.finv[a]%mod)*comb.finv[b]
    println(fact%mod)
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun Int.pow(n:Int) = Math.pow(this.toDouble(), n.toDouble())

class Comb(max:Int, mod:Int) {
    val fac  = LongArray(max+1).apply { this[0] = 1L; this[1] = 1L }
    val finv = LongArray(max+1).apply { this[0] = 1L; this[1] = 1L }
    val inv  = LongArray(max+1).apply { this[1] = 1L }

    init {
        for (i in 2 .. max) {
            fac[i] = fac[i - 1] * i % mod
            inv[i] = mod - inv[mod % i] * (mod / i) % mod
            finv[i] = finv[i - 1] * inv[i] % mod
        }
    }
}