fun main(args: Array<String>) {

    /**
     * 累乗の計算
     * a^n mod を計算する
     */
    fun pow(a: Long, b: Long, mod: Int): Long {
        var at = a
        var bt = b
        var ret: Long = 1
        while (bt > 0) {
            if (bt and 1 == 1L) {
                ret = ret * at % mod
            }
            at = at * at % mod
            bt = bt shr 1
        }
        return ret
    }


    /**
     * 組み合わせ
     */
    fun nCk(n: Int, k: Int, mod: Int): Int {
        var ret: Long = 1
        val min = Math.min(k, n - k)
        for (i in 1..min) {
            ret = ret * pow(i.toLong(), (mod - 2).toLong(), mod) % mod
        }
        for (i in n - min + 1..n) {
            ret = ret * i % mod
        }
        return ret.toInt()
    }

    val MOD = 1000000007

    val (x, y) = readLine()!!.split(" ").map(String::toInt)

    val totalMove = (x + y) / 3
    val xCount = x - totalMove
    val yCount = y - totalMove

    if ((x + y) % 3 != 0 || xCount < 0 || yCount < 0) {
        println(0)
        return
    }


    println(nCk(totalMove, xCount, MOD) % MOD)

}


