A, B, C, D = gets.split(' ').map(&:to_i) count = 0 (A..B).each do |i| (C..D).each do |j| count += 1 if i != j end end puts count