MOD = 10 ** 9 + 7

x, y = gets.chomp.split.map(&:to_i)
if (2 * x - y) % 3 != 0 || (2 * y - x) % 3 != 0
  puts "0"
elsif 2 * x < y || 2 * y < x
  puts "0"
else
  h = (2 * x - y) / 3
  w = (2 * y - x) / 3
  m = 10 ** 6 - 1

  inv = Array.new(m + 1)
  m.times do |i|
    if i == 0
      inv[i + 1] = 1
    else
      inv[i + 1] = (- inv[MOD % (i + 1)] * (MOD / (i + 1))) % MOD
    end
  end
  
  r = [h, w].min
  comb = Array.new(r + 1)
  comb[0] = 1

  r.times do |i|
    comb[i + 1] = comb[i] * (h + w - i) * inv[i + 1] % MOD
  end

  puts comb[r]
end