import java.util.*

fun main(args: Array<String>) {
    val result = solve(Scanner(System.`in`))
    if (result.isNotEmpty()) println(result)
}

const val MOD = 1000000007L

fun modMul(a: Long, b: Long): Long = (a * b) % MOD

fun modDiv(a: Long, b: Long): Long = (a * modPow(b, MOD - 2)) % MOD

fun modPow(a: Long, p: Long): Long = when {
    p == 0L -> 1
    p % 2 == 1L -> (a * modPow(a, p - 1)) % MOD
    else -> {
        val half = modPow(a, p / 2)
        (half * half) % MOD
    }
}

fun solve(sc: Scanner): String {
    val X = sc.nextInt()
    val Y = sc.nextInt()

    if ((X + Y) % 3 != 0) {
        return "0"
    }
    val a = ((2 * Y) - X) / 3
    val b = ((2 * X) - Y) / 3
    if (b < 0 || a < 0) {
        return "0"
    }

    var result = 1L
    for (i in (b + 1)..(a + b)) {
        result = modMul(result, i.toLong())
    }
    for (i in (1..a)) {
        result = modDiv(result, i.toLong())
    }

    return result.toString()
}
