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