x,y = gets.split.map(&:to_i)
a = ((2*y)-x).to_f/3
b = ((2*x)-y).to_f/3
if ((2*x)-y) % 3 != 0 || ((2*x)-y) % 3 != 0
  puts "0"
else
  sumab = 1
  suma = 1
  for i in ((b+1).to_i)..((a+b).to_i)
    sumab *= i
  end
  for j in 1..(a.to_i)
    suma *= j
  end
  
  puts (sumab*(suma.to_bn.mod_inverse(10**9+7).to_i)) % (10**9+7)
end