#include <bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
#define erep(i,l,r) for(int (i)=(l);(i)<=(r);(i)++)
#define MOD 1000000007
using namespace std;
#define ll long long
ll inv(ll a){
  ll t=1;
  while (a>1){
    t=t*(MOD-MOD/a)%MOD;
    a=MOD%a;
  }
  return t;
}
ll comb(ll n,ll k){
  if (k>n-k) k=n-k;
  ll nu=1,de=1;
  rep(i,1,k+1){
    nu=nu*(n+1-i)%MOD;
    de=de*i%MOD;
  }
  return nu*inv(de)%MOD;
}
ll nHr(ll n, ll r){
    return comb(n+r-1,r);
}
int main(){
    ll x,y,i=-1,j=-1;
    cin>>x>>y;
    if((2*x-y)%3==0)i=(2*x-y)/3;
    if((2*y-x)%3==0)j=(2*y-x)/3;
    if(i<0||j<0)cout<< "0" <<endl;
    else cout<< comb(i+j,j) <<endl;
}