const val MOD = 1000000007L

fun main(args: Array<String>) {
    val (X, Y) = listOfInt()
    var s = X + Y
    if (s % 3 != 0) {
        println(0)
        return;
    }
    s /= 3
    val x = X - s
    val y = Y - s
    if (x < 0 || y < 0) {
        println(0)
        return;
    }
    val ans = FermatCombination(x + y).combine(x + y, x).toString()
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)

class FermatCombination(size: Int) {
    var factrial = LongArray(size + 1)
    var inverse = LongArray(size + 1)
    init {
        factrial[0] = 1
        inverse[0] = 1
        for (i in 1 .. size) {
            factrial[i] = factrial[i - 1] * i % MOD
            inverse[i] = pow(factrial[i], MOD.toInt() - 2) % MOD
        }
    }
    fun combine(n: Int, k: Int): Long {
        if (n < k || n < 0 || k < 0) return 0
        return factrial[n] * inverse[k] % MOD * inverse[n - k] % MOD
    }
    fun pow(x: Long, n: Int): Long {
        var x = x
        var n = n
        var ans: Long = 1
        while (n > 0) {
            if (n and 1 == 1) {
                ans = ans * x % MOD
            }
            x = x * x % MOD
            n = n shr 1
        }
        return ans
    }
}
