g = gets.chomp.split(' ').map(&:to_i)

# g[0] = i + 2j
# g[1] = 2i + j
i = (2 * g[1] - g[0]) / 3
j = (2 * g[0] - g[1]) / 3
num = i+j
if num == 0
  puts 0
else
  a = (i < j) ? j : i
  numerator = [*(a+1..num)].inject(:*)
  denominator = [*(1..a)].inject(:*)
  puts (numerator / denominator) % ((10 ** 9) + 7)
end
