MOD=(10**9)+7
$fac=[]
$finv=[]
$inv=[]
$fac[0] = 1
$fac[1] = 1
$inv[0] = 1
$finv[1] = 1
$inv[1] = 1
for i in 2..1000000*2/3
  $fac[i] = $fac[i - 1] * i % MOD
  $inv[i] = MOD - $inv[MOD%i] * (MOD / i) % MOD
  $finv[i] = $finv[i - 1] * $inv[i] % MOD
end

def com(n,k)
  return 0 if n<k
  return 0 if(n<0 || k<0)
  return $fac[n] * ($finv[k] * $finv[n - k] % MOD) % MOD;
end



x,y=gets.chomp.split(" ").map{|s| s.to_i}
if (x+y)%3!=0
  p 0
  exit
end

u=[x,y].max
v=[x,y].min
c=0
while u!=v && u>=0 && v>=0
  u-=2
  v-=1
  c+=1
end
if u<0 ||v<0
  p 0
  exit
end


p=u/3

p com(c+p*2,p)%MOD
