import std.algorithm;
import std.bigint;
import std.bitmanip;
import std.concurrency : generator = Generator, yield;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


immutable long MOD = 1000000007;


auto solve(long X, long Y) {
    if ((2 * X - Y) % 3 != 0 || (2 * Y - X) % 3 != 0)
        return 0;
    
    const a = (2 * Y - X) / 3;
    const b = (2 * X - Y) / 3;

    if (a < 0 || b < 0)
        return 0;

    return ModCalc(MOD).C(a + b, a);
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long X;
    X = input.front.to!long;
    input.popFront;

    long Y;
    Y = input.front.to!long;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(X, Y);
    else {
        auto ans = solve(X, Y);

        static if (isFloatingPoint!(ReturnType!solve))
            writeln(format("%.9f", ans));
        else static if (is(ReturnType!solve == bool))
            writeln(ans ? YES : NO);
        else
            writeln(ans);
    }
}


struct ModCalc {
private:
    long mod;
    long[] fac;
    long[] inv;
    long[] finv;

public:
    this(long mod) {
        this.mod = mod;
        fac = [1, 1];
        inv = [0, 1];
        finv = [1, 1];
    }

    long factorial(long n) {
        assert(n >= 0);

        auto n_ = n.to!size_t;
        extendTable(n_ + 1);
        return fac[n_];
    }

    long P(long n, long k) {
        assert(0 <= k && k <= n);

        auto n_ = n.to!size_t;
        auto k_ = k.to!size_t;
        extendTable(n_ + 1);
        return fac[n_] * finv[n_ - k_] % mod;
    }

    long C(long n, long k) {
        assert(0 <= k && k <= n);

        auto n_ = n.to!size_t;
        auto k_ = k.to!size_t;
        extendTable(n_ + 1);
        return fac[n_] * finv[k_] % mod * finv[n_ - k_] % mod;
    }

    long H(long n, long k) {
        return C(n + k - 1, k);
    }

private:
    void extendTable(size_t size) {
        auto oldsize = fac.length;
        if (size <= oldsize)
            return;

        fac.length = size;
        inv.length = size;
        finv.length = size;

        foreach (i; oldsize .. size) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[(mod % i).to!size_t] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
}
