function main(arg) {
    var a = arg.split(/\s/g)[0];
    var b = arg.split(/\s/g)[1];
    var x = (2*b-a)/3;
    var y = (2*a-b)/3;
    if(Number.isInteger(x)|Number.isInteger(y)){
        console.log(combination(x+y,x));
    }else{
        console.log(0);
    }
}

function permutation(n, r) {
for(var i = 0, res = 1; i < r; i++) {
res *= n - i;
}
return res;
}

function combination(n, r) {
return permutation(n, r) / permutation(r, r);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));