import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

enum MAX = 1_000_100;
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias Pass = Tuple!(long, "x", long, "y");

long[MAX] fac;
long[MAX] inv;
long[MAX] finv;

void combinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    foreach (i; iota(2, MAX))
    {
        fac[i] = i * fac[i - 1] % MOD;
        inv[i] = MOD - (inv[MOD % i] * (MOD / i)) % MOD;
        finv[i] = inv[i] * finv[i - 1] % MOD;
    }
}

auto comb(long n, long k)
{
    if (n < k || n < 0 || k < 0)
        return 0;
    else
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void main()
{
    long x, y;
    scan(x, y);
    long fst, snd;
    fst = 2 * x - y;
    snd = 2 * y - x;
    if (fst < 0 || snd < 0)
        writeln(0);
    else if (fst % 3 || snd % 3)
        writeln(0);
    else
    {
        fst /= 3;
        snd /= 3;
        combinit();
        (fst + snd).comb(fst).writeln();
    }
}

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}
