X, Y = gets.split.map(&:to_i)

# f = x+=1, y+=2
# g = x+=2, y+=1

def combi(n,k)
  k=n-k if 2*k > n
  return 1 if k == 0
  ((n-k+1)..n).reduce(&:*)/((1..k).reduce(&:*))
end

if (X + Y) % 3 != 0
  puts 0
elsif Y > 2 * X
  puts 0
elsif Y < (1/2) * X
  puts 0
else
  total = (X + Y) / 3
  (0).upto(total) do |i|
    if X == i * 1 + (total - i) * 2
      ret = combi(total, i)
      puts ret.modulo((10**9) + 7)
      break
    end
  end
end