a,b,c,d = gets.split.map(&:to_i)
ans = 0
(a..b).each do |x|
  (c..d).each do |y|
    ans += 1 if x != y
  end
end
puts ans