S = gets.split.map(&:to_i) R = (S[0] .. S[1]).to_a B = (S[2] .. S[3]).to_a puts R.product(B).count{|a,b| a != b }