x,y = gets.chomp.split(' ').map(&:to_i)

# x = i + 2j
# y = 2i + j
#i = (2 * y - x) / 3
#j = (2 * x - y) / 3
#i + j = (x + y) / 3
num = (x+y)
step = num / 3

if num % 3 != 0 || x < step || y < step
  puts 0
  exit
end

i = x - step
j = y - step
a = 1
j.times do |jj|
  a *= i + jj + 1
  a /= jj + 1
end
a %= 100000007
puts a
