#include <iostream>
#include <limits>
#include <queue>
#include <tuple>

#define MOD (int)(1e9 + 7)
using ll = long long;

using namespace std;

template <int mod>
struct ModInt
{
    int x_;

    ModInt() : x_(0) {}
    ModInt(int64_t y) : x_(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p)
    {
        if ((x_ += p.x_) >= mod)
            x_ -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p)
    {
        if ((x_ += mod - p.x_) >= mod)
            x_ -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p)
    {
        x_ = (int)(1LL * x_ * p.x_ % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p)
    {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x_); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x_ == p.x_; }
    bool operator!=(const ModInt &p) const { return x_ != p.x_; }

    ModInt inverse() const
    {
        int a = x_, b = mod, u = 1, v = 0, t;
        while (b > 0)
        {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const
    {
        ModInt ret(1), mul(x_);
        while (n > 0)
        {
            if (n & 1)
                ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x_; }
    friend istream &operator>>(istream &is, const ModInt &a)
    {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return is;
    }
    static int get_mod() { return mod; }
};

template <typename T>
struct Combination
{
    vector<T> fact_, rfact_, inv_;

    Combination(int siz) : fact_(siz + 1), rfact_(siz + 1), inv_(siz + 1)
    {
        fact_[0] = rfact_[siz] = inv_[0] = 1;
        for (int i = 1; i <= siz; i++)
            fact_[i] = fact_[i - 1] * i;
        rfact_[siz] /= fact_[siz];
        for (int i = siz - 1; i >= 0; i--)
            rfact_[i] = rfact_[i + 1] * (i + 1);
        for (int i = 1; i <= siz; i++)
            inv_[i] = rfact_[i] * fact_[i - 1];
    }

    inline T fact(int k) const { return fact_[k]; }
    inline T rfact(int k) const { return rfact_[k]; }
    inline T inv(int k) const { return inv_[k]; }

    // 順列の場合の数
    T P(int n, int r) const
    {
        if (r < 0 || n < r)
            return 0;
        return fact(n) * rfact(n - r);
    }

    // 組み合わせ
    T C(int n, int r) const
    {
        return fact(n) * rfact(n - r) * rfact(r);
    }

    // 重複組み合わせ
    T H(int n, int r) const
    {
        if (n < 0 || n < r)
            return 0;
        return r == 0 ? 1 : C(n + r - 1, r);
    }
};

using Comb = Combination<ModInt<MOD>>;

int main()
{
    ll x, y;
    cin >> x >> y;

    ll a = -x + 2 * y;
    ll b = 2 * x - y;

    if (!(a >= 0 && b >= 0 && (a % 3) == 0 && (b % 3) == 0))
    {
        cout << 0 << endl;
        return 0;
    }

    a /= 3, b /= 3;
    Comb cmb(a + b);
    cout << cmb.C(a + b, a) << endl;
}

Measured memory_bytes: 8064