def rec(n, p, m)
  return 1 if p == 0
  if p % 2 == 0
    tmp = rec(n, p / 2, m)
    return tmp * tmp % m
  end
  n * rec(n, p - 1, m) % m
end
x, y = gets.chomp.split(' ').map(&:to_i)
xy = x + y
mod = (1e+9 + 7).to_i
if xy % 3 != 0
  puts 0
else
  n = xy / 3
  if !(x >= n && x <= 2 * n && y >= n && y <= 2 * n)
    puts 0
  else
    r = x - n
    arr = Array.new(n)
    arr[0] = 1
    (1...n).each do |i|
      arr[i] = arr[i - 1] * (i + 1) % mod
    end
    arr.unshift(1)
    a = arr[n]
    b = arr[n - r]
    c = arr[r]
    bc = (b * c) % mod
    puts (a * rec(bc, mod - 2, mod)) % mod
  end
end
