x,y=gets.strip.split.map(&:to_i)
if(x+y)%3!=0
  p 0;exit
end

k=x-(x+y)/3
l=y-(x+y)/3

MOD = 10**9+7
 
def power(x, n)
  return 1 if n.zero?
 
  if n.even?
    return power(x*x, n/2) % MOD
  else
    return x*power(x, n/2)**2 % MOD
  end
end

$fac = []
$fac[0] = $fac[1] = 1
2.upto(k+l) do |num|
  $fac[num] = num * $fac[num-1] % MOD
end

$ifac = []
$ifac[0] = $ifac[1] = 1
$ifac[k+l] = power($fac[k+l], (MOD-2)) % MOD
(k+l-1).downto(2) do |num|
  $ifac[num] = $ifac[num+1] * (num+1) % MOD
end

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

p comb(k+l,k)