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


def derive_inverse(m, modu)
  i = 0
  res = 1
  while !(res % num == 0) do
    res += modu
    i += 1
  end
  return inv = (1 + i * modu) / num
end


if (2 * Y - X) % 3 == 0 && (2 * X - Y) % 3 == 0
  m = (2 * Y - X) / 3
  n = (2 * X - Y) / 3 
  answer = 1
  if m < n
    ele = m
  else
    ele = n
  end
  denominator = 1
  ele.times do |i|
    denominator = denominator * (i+1) 
    answer = ((answer * (n + 1 + i) ) % modu )
  end
  denominator = derive_inverse(denominator,modu)
  answer = answer * denominator
else
  answer = 0
end

puts answer % modu
