fun main(args: Array<String>) {
    val (x, y) = readIntegerList()
    if (y * 2 < x || x * 2 < y || (x + y) % 3 != 0) {
        println(0)
        return
    }

//    y = -x + b
//    b = y1 + x1
//    y = -x + x1 + y1
//    -----------
//    y = x / 2
//    -2x + 2x1 + 2y1 = x
//    x = 2 * (x1 + y1) / 3
//    y = (x1 + y1) / 3
    val lowX = 2 * (x + y) / 3
    val lowY = (x + y) / 3
    val cX = lowX / 2
    val cY = y - lowY
    val table = Combination(1000000)
    println(table.value(cX, cY))

}

/** n <= 1000000 */
class Combination(n: Int, val MOD: Long = 1000000007L) {
    val fact = LongArray(n + 1)
    val ifact = LongArray(n + 1)
    
    /** O(n) */
    init {
        fact[0] = 1L
        for (i in 1..n) { fact[i] = (fact[i - 1] * i) % MOD }
        ifact[n] = inverse(fact[n], MOD)
        for (i in n downTo 1) { ifact[i - 1] = (ifact[i] * i) % MOD }
    }

    /** O(1) */
    fun value(n: Int, k: Int) = if (k < 0 || k > n) 0 else (((fact[n] * ifact[k]) % MOD) * ifact[n-k]) % MOD
    
    /** O(log(m)) */
    fun pow(n: Long, m: Long, MOD: Long): Long {
        var ret = 1L
        var x = n
        var k = m
        while (k > 0) {
            if ((k and 1L) == 1L) { ret = (ret * x) % MOD }
            x = (x * x) % MOD
            k = k shr 1
        }
        return ret
    }

    /** O(log(MOD)) */
    fun inverse(n: Long, MOD: Long) = pow(n, MOD - 2L, MOD)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
