#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define vi vector<int>
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

const int MOD = 1e9 + 7;
const int INF = 1 << 30;


class UnionFind{
private:
        vector<int> par,rank,sizes;
        int tree;

public:
        explicit UnionFind(const int n) : tree(n){
            par.resize(n+1);
            rank.resize(n+1);
            sizes.resize(n+1);
            rep(i,n){
                par[i] = i;
                sizes[i] = 1;
            }
        }

        ~UnionFind() = default;

        int root(int x){
            if(par[x] == x) return x;
            else return par[x] = root(par[x]);
        }

        int find(int x){ return root(x);}

        void unite(int x, int y) {
            x = root(x);
            y = root(y);
            if (x == y) return;

            if (rank[x] < rank[y]) swap(x, y);
            par[y] = x;
            tree--;
            sizes[x] += sizes[y];
            if (rank[x] == rank[y]) rank[x]++;
        }

        bool same(int x, int y){
            return root(x) == root(y);
        }

        int size(int x){
            return sizes[root(x)];
        }

        int sumTree(){
            return tree;
        }
};

template <typename T>
class segmentTree{
private:
    int n;
    vector<T> arr;
public:

    explicit segmentTree(vector<T> v){
        ll sz = v.size();
        //while()

        arr.resize(2*n - 1);

    }

    T &operator[](int n){ return arr[n];}


};

template <int mod>
class ModInt{
private:
    ll _num;

public:
    ModInt(){_num = 0;}
    explicit ModInt(ll value){_num = value%mod;}

    ModInt operator+(ModInt &x){ return ModInt(_num + x._num);}
    ModInt operator-(ModInt &x){ return ModInt(_num - x._num);}
    ModInt operator*(ModInt &x){ return ModInt(_num * x._num);}
    friend ostream &operator<<(ostream &os, const ModInt &x){os<<x._num; return os;}
    friend istream &operator>>(istream &is, ModInt &x){is>>x._num; return is;}
};
using mint = ModInt<MOD>;

ll power(ll m, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = ((res%mod) * (m%mod))%mod;
        m = (m * m)%mod;
        n >>= 1;
    }
    return res;
}
//const ll MOD=998244353ll;
const int MAX=1000000;

ll fact[MAX], fact_inv[MAX];

// 繰り返し二乗法
ll power(ll a, ll b){
    ll res=1;
    while(b>0){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}

ll comb(ll n, ll r){
    return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n=1000000;
    // cin>>n;
    fact[0]=1;
    // 階乗の計算
    rep(i, n) fact[i+1]=fact[i]*(i+1)%MOD;
    fact_inv[n]=power(fact[n], MOD-2);
    // 逆元の計算
    rrep(i, 0, n) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
    // nCrの計算
    //cout<<"6C3: "<<comb(6, 3)<<'\n';
    //cout<<"666C390: "<<comb(666, 390)<<'\n';

    int x,y; cin >> x >> y;
    if(y > x) swap(x,y);

    int ans = 0;

    if((x+y)%3 == 0 and x <= 2 * y){
        int maxx = (x+y)/3*2;
        ans = comb((x+y)/3,maxx-x);
    }

    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 15872