input = gets.chomp.split(" ").map(&:to_i)
X = input[0]
Y = input[1]
modu = 10 ** 9 + 7

inverses = []

def derive_inverse(m, modu, inverses=[])
  (1..m).each do |num|
    i = 0
    res = 1
    while !(res % num == 0) do
      res += modu
      i += 1
    end
    inv = (1 + i * modu) / num
    inverses << inv
  end
end


if (2 * Y - X) % 3 == 0 && (2 * X - Y) % 3 == 0
  m = (2 * Y - X) / 3
  n = (2 * X - Y) / 3 
  answer = 1
  derive_inverse(m,modu,inverses)
  m.times do |i|
    answer = ((answer * (n + 1 + i) ) % (10 **9 + 7) )* inverses[i]
  end
else
  answer = 0
end

puts answer % modu
