#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
const int MOD = 1e9+7, MX = 1e6+5;
int x,y,z;
ll exp(ll b, ll n){
	ll res = 1;
	for(; n; n/=2,(b*=b)%=MOD) if(n%2) (res *= b) %= MOD;
	return res;
}
ll fact[MX] = {1}, invf[MX];
void setcomb(int n){
	for(int i = 1; i <= n; i++) fact[i] = (fact[i-1] * i) % MOD;
	invf[n] =  exp(fact[n] ,MOD-2);
	for(int i = n; i > 0; i--) invf[i-1] = (invf[i] * i) % MOD;
}
inline ll comb(int a, int b){return fact[a] * invf[a-b] % MOD * invf[b] % MOD;}
int main(){
	scanf("%d%d", &x, &y);
	if((x+y)%3) return 0*puts("0");
	z = (x+y)/3;
	x -= z; y -= z;
	setcomb(z);
	printf("%lld\n", comb(z,x));
}