x1, y1, w1, h1 = gets.chomp.split.map(&:to_i)
x2, y2, w2, h2 = gets.chomp.split.map(&:to_i)
left = [x1, x2].max
right = [x1 + w1, x2 + w2].min
bottom = [y1, y2].max
top = [y1 + h1, y2 + h2].min
width = (left < right ? right - left : 0)
height = (bottom < top ? top - bottom : 0)
puts w1 * h1 + w2 * h2 - width * height * 2
