# frozen_string_literal: true

input = gets.chomp.split(' ').map(&:to_i)
X = input[0]
Y = input[1]
modu = 1_000_000_007

# def derive_inverse(num, modu)
#   i = 0
#   res = 1
#   until (res % num).zero?
#     res += modu
#     i += 1
#   end
#   (1 + i * modu) / num
# end
def derive_inverse(_num, modu)
  result = 1
  (1..(modu - 2)).each do |e|
    result = result**2 % modu
  end
  return result
end

# def derive_inverse(num, modu)
#   return num.pow(modu-2,  modu)
# end

if ((2 * Y - X) % 3).zero? && ((2 * X - Y) % 3).zero? && (2 * Y - X >= 0) && (2 * X - Y >= 0)
  m = (2 * Y - X) / 3
  n = (2 * X - Y) / 3

  answer = 1

  if m < n
    ele = m
    elem = n
  else
    ele = n
    elem = m
  end

  deno = 1
  ele.times do |i|
    deno = deno * (i + 1) % modu
    answer = answer * (elem + 1 + i) % modu
  end
  deno = derive_inverse(deno, modu)
  answer = answer * deno % modu
else
  answer = 0
end

puts answer % modu
