a,b,c,d = gets.split.map(&:to_i) p (a..b).map{|x| (c..d).map {|y| [x,y]}}.flatten(1).filter{|x|x[0] != x[1]}.size