function Main(arg) {
 
    var X = arg.split("\n")[0].split(" ")[0]-0;
    var Y = arg.split("\n")[0].split(" ")[1]-0;

    if ((2 * X - Y) % 3 !== 0) {
        console.log(0);
    }

    var m = (2 * X - Y) / 3;
    var n = X - 2 * m;

    var tmp = new Array(n+1);
    for (var i = 0; i <= n; i++) {
        tmp[i] = new Array(m+1);
    }
    tmp[0][0] = 0;
    tmp[0][1] = 1;
    tmp[1][0] = 1;
    for (var i = 1; i <= n; i++){
        for (var j = 1; j <= m; j++){
            tmp[i][j] = tmp[i-1][j] + tmp[i][j-1];      
        }
    }

    console.log(tmp[n][m]%(Math.pow(10, 9)+7));

    return;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));