val mod = 1000000007

fun mul(a: Long, b: Long) = (a * b) % mod

fun inv(n: Long): Long {
    var b = 1
    var v = n
    var ret = 1L
    while (b <= mod - 2) {
        if (b and (mod - 2) != 0) {
            ret = mul(ret, v)
        }
        v = mul(v, v)
        b *= 2
    }
    return ret
}

fun div(a: Long, b: Long) = (a * inv(b)) % mod

fun fac(n: Long) = (1L .. n).fold(1L) { a, b -> mul(a, b) }

fun cmb(n: Long, r: Long) = div(div(fac(n), fac(r)), fac(n - r))

fun main(args: Array<String>) {
    val (x, y) = readLine()!!.split(" ").map { it.toLong() }.let {
        Pair(it[0], it[1])
    }
    println(if ((x + y) % 3 != 0L || x * 2 < y || y * 2 < x) {
        0
    } else {
        cmb((x + y) / 3, (x * 2 - y) / 3)
    })
}
