#include<bits/stdc++.h>
using namespace std;

//Commands and Functions
#define LCM(a,b)                (a / __gcd(a,b) ) *b
#define GCD(a,b)                __gcd(a,b)
#define dist(x1,y1,x2,y2)       sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define distl(x1,y1,x2,y2)      sqrtl((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define SQR(a)                  ((a)*(a))
#define fRead(x)                freopen(x,"r",stdin)
#define fWrite(x)               freopen (x,"w",stdout)
#define getarray(a,n)           for(int i=0;i<n;i++) cin>>a[i]
#define pb                      push_back
#define mk                      make_pair
#define ff                      first
#define ss                      second
#define lb                      lower_bound
#define ub                      upper_bound
#define tcase                   cout<<"Case "<<C++<<": ";
#define all(a)                  a.begin(),a.end()
#define lla(A)                  A.rbegin(), A.rend()
#define Unique(a)               sort(all(a)),a.erase(unique(all(a)),a.end
#define lastEle(v)              v[v.size()-1]
#define ABS(x)                  ((x)<0?-(x):(x))
#define min3(a,b,c)             min(a,min(b,c))
#define min4(a,b,c,d)           min(a,min(b,min(c,d)))
#define max3(a,b,c)             max(a,max(b,c))
#define max4(a,b,c,d)           max(a,max(b,max(c,d)))
#define max5(a,b,c,d,e)         max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e)         min(min3(a,b,c),min(d,e))
#define MEM(a,x)                memset(a,x,sizeof(a))
#define Godspeed                ios_base::sync_with_stdio(0);cin.tie(NULL)
#define FOR(i,a,b)              for(long long int i=a;i<=b;i++)
#define ROF(i,a,b)              for(int i=a;i>=b;i--)
#define REP(i,b)                for(int i=0;i<b;i++)
#define PER(i,a,b)              for(int i=a;i>b;i--)
#define FOREACH(i,t)            for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define PRESENT(c,x)            ((c).find(x) != (c).end())
#define CPRESENT(c,x)           (find(ALL(c),x) != (c).end())
#define Lower_bound(v, x)       distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)       distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Bye                     return 0
#define SORT(v)                 sort(v.begin(),v.end())
#define REV(v)                  reverse(v.begin(),v.end())
#define EVEN(x)                 return x&1==0?1:0
#define ODD(x)                  return x&1==0?0:1
#define Debug                   cout<<endl<<"I AM BATMAN"<<endl;
//ll powmod(ll a,ll b)           {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int PowMod(int a,int l, int md)
{
    int res=1;
    while(l)
    {
        if(l&1)
            res=res*a%md;
        l/=2;
        a=a*a%md;
    }
    return res;
}
int phi(int n)
{
    int result = 1;
    for (int i = 2; i < n; i++)
        if (GCD(i, n) == 1)
            result++;
    return result;
}
int isprime(int n)
{
    bool flag = false;
    for(int i = 2; i <= n/2; ++i)
        //for(int i = 2; i <= sqrt(n); ++i)
    {
        if(n%i == 0)
        {
            flag = true;
            break;
        }
    }
    return flag;
}
//Formulae
/*No. of Diagonals of regular n-gon=n*(n-3)/2;
No. of Intersections(for odd n)=ceil(((pow(n,4)-(6*pow(n,3))+(11*pow(n,2))-(6*n)))/24);
*/
//Datatypes
#define ll                      long long
#define ULL                     unsigned long long
#define LD                      long double
#define UI                      unsigned int
#define US                      unsigned short

//Constants
const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const ll inf = 0xFFFFFFFFFFFFFFFL;
#define PI                      acos(-1.0)
#define EulerGamma              0.57721566490153286060651209
//Data Structures
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pdd pair<double,double>
#define pldld pair<long long double, long long double>
/*
    Syed Rifat Raiyan
    IUT CSE-18
    Go Beyond! Plus Ultra!
*/
ll f1[1000001],f2[1000001],f3[1000001];
void init()
{
    f1[0]=f1[1]=f2[0]=f2[1]=f3[1]=1;
    FOR(i,2,1000001)
    {
        f1[i] = f1[i - 1] * i % MOD;
        f3[i] = MOD - f3[MOD%i] * (MOD / i) % MOD;
        f2[i] = f2[i - 1] * f3[i] % MOD;
    }
}
ll resolve(ll a, ll b)
{
    if(a<b || a<0 || b<0)
    {
        return 0;
    }
    else
    {
        return f1[a]*(f2[b]*f2[a-b]%MOD)%MOD;
    }
}
int main()
{
    Godspeed;
    ll x,y,n,i;
    //bool flag=true;
    cin>>x>>y;
    if((x+y)%3!=0)
    {
        cout<<0;
        Bye;
    }
    else
    {
        n=(x+y)/3;
        if(x-n<0 || 2*n-x<0)
        {
            cout<<0;
            Bye;
        }
        else
        {
            init();
            ll res=resolve(n,x-n);
            cout<<res;
            Bye;
        }
    }
    Bye;
}


Measured memory_bytes: 23808