ary = {}
gets.to_i.times {
    a = gets.split(" ").map {|s| s.to_i }
    (a[0]...a[2]).each {|x|
        (a[1]...a[3]).each{|y|
            ary[x] = [] if ary[x].nil?
            ary[x] << y
        }
    }
}

puts ary.map {|a| a.nil? ? 0 : a.uniq.count }.reduce {|sum, n| sum + n }