#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

using fint64 = int_fast64_t;
template<fint64 MOD>
struct ModInt{
    fint64 x;
    ModInt():x(0){}
    ModInt(fint64 x):
        x(x>=0?x%MOD:(MOD-(-x)%MOD)%MOD)
        {}
    // 負号
    ModInt operator -() const{
        return ModInt(-x);
    }
    // 加算
    ModInt &operator +=(const ModInt &rhs){
        x+=rhs.x;
        if(x>=MOD) x-=MOD;
        return (*this);
    }
    ModInt operator +(const ModInt &rhs) const{
        return ModInt(*this)+=rhs;
    }
    // 減算
    ModInt &operator -=(const ModInt &rhs){
        x+=MOD-rhs.x;
        if(x>=MOD) x-=MOD;
        return (*this);
    }
    ModInt operator -(const ModInt &rhs) const{
        return ModInt(*this)-=rhs;
    }
    // 乗算
    ModInt &operator *=(const ModInt &rhs){
        x*=rhs.x;
        if(x>=MOD) x%=MOD;
        return (*this);
    }
    ModInt operator *(const ModInt &rhs) const{
        return ModInt(*this)*=rhs;
    }
    // 除算
    ModInt &operator /=(const ModInt &rhs){
        (*this)*=rhs.inverse();
        return (*this);
    }
    ModInt operator /(const ModInt &rhs) const{
        return ModInt(*this)/=rhs;
    }
    // 等号
    bool operator ==(const ModInt &rhs){
        return x==rhs.x;
    }
    bool operator !=(const ModInt &rhs){
        return x!=rhs.x;
    }
    // 累乗
    ModInt pow(fint64 n) const{
        fint64 tmp=x;
        fint64 ret=1;
        while(n>0){
            if(n&1) ret=ret*tmp%MOD;
            tmp=tmp*tmp%MOD;
            n>>=1ll;
        }
        return ModInt(ret);
    }
    // 逆元
    ModInt inverse() const{
        fint64 a=x,b=MOD,s=1,t=0;
        while(b>0){
            fint64 u=a/b;
            a-=u*b;
            s-=u*t;
            swap(a,b);
            swap(s,t);
        }
        return ModInt(s);
    }
    // 入出力
    friend istream &operator >>(istream &lhs,ModInt<MOD> &rhs){
        fint64 x; lhs>>x;
        rhs=ModInt<MOD>(x);
        return lhs;
    }
    friend ostream &operator <<(ostream &lhs,const ModInt<MOD> &rhs){
        return lhs<<rhs.x;
    }
};

using fint64 = int_fast64_t;
struct Combination {
	const int MAX = 5000010;
	const int MOD;
	vector<fint64> FAC;
	vector<fint64> INV;
	vector<fint64> FAC_INV;
	Combination(fint64 MOD) :
		MOD(MOD),
		FAC(vector<fint64>(MAX)),
		INV(vector<fint64>(MAX)),
		FAC_INV(vector<fint64>(MAX))
		{
			FAC[0] = INV[1] = FAC_INV[0] = 1;
			for(int i = 1; i < MAX; ++i) {
				FAC[i] = FAC[i - 1] * i % MOD;
				if(i > 1) INV[i] = MOD - INV[MOD % i] * (MOD / i) % MOD;
				FAC_INV[i] = FAC_INV[i - 1] * INV[i] % MOD;
			}
		}
	fint64 C(int n, int r) {
		if(n < 0 or r < 0 or n < r) return 0;
		return FAC[n] * FAC_INV[r] % MOD * FAC_INV[n - r] % MOD;
	}
	fint64 P(int n, int r) {
		if(n < 0 or r < 0 or n < r) return 0;
		return FAC[n] * FAC_INV[n - r] % MOD;
	}
	fint64 H(int n, int r) {
		if(r == 0) return 1;
		return C(n + r - 1, r);
	}
};

int main() {
	using mint = ModInt<MOD>;
	Combination com(MOD);
	int x, y; cin >> x >> y;
	mint ans = 0;
	for(int a = 0; a <= x; ++a) {
		if((x - a) % 2 != 0) continue;
		int b = (x - a) / 2;
		if(2 * a + b != y) continue;
		ans += com.C(a + b, a);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 117504