import java.util.*

const val mod = 1000000007L
fun main(args: Array<String>) {
    val (x, y) = readLine()!!.split(" ").map { it.toInt() }

    if ((x + y) % 3 != 0) {
        println(0)
        return
    }

    val n = ((x + y) / 3).toLong()
    val k = Math.min(x, y) - n

    if (k < 0) {
        println(0)
        return
    }


    var r = factorial(n)
    var a = factorial(k)
    var b = factorial(n - k)
    var c = (a * b) % mod
    var d = inverse(c)
    var e = (r * d) % mod

    //println("$a $b $c $d $e")
    println(e)
}

fun factorial(n: Long): Long {
    var r = 1L
    (1..n).forEach { r = (r * it) % mod }
    return r
}

fun inverse(n: Long): Long {
    return pow(n, mod - 2)
}

fun pow(n: Long, k: Long): Long { // n ^ k
    if (k == 0L) return 1
    if (k == 1L) return n

    val res = pow(n, k / 2)
    var r = (res * res) % mod
    if (k % 2 == 1L) r = (r * n) % mod
    return r
}
