a,b,c,d = gets.chomp.split(" ").map(&:to_i) count = 0 (a..b).each do |i| ary = (c..d).to_a ary.delete(i) count += ary.length end puts count