x, y = gets.split.map(&:to_i)
if ((x + y) % 3 != 0) || (x < y/2) || (y < x/2) then
  puts 0
else
  k3 = (x + y) / 3
  k1 = [x, y].min - k3
  k2 = k3 - k1 + 1
  puts ( ( [1,*(k2..k3)].inject(:*) ) / ( ([1,*(1..k1)]).inject(:*) ) ) % (10**9 + 7)
end