n, m = gets.split.map(&:to_i)
queue = []
(1..n).each do |id|
	s, t = gets.split.map(&:to_i)
	s, t = -s, -t if s > t
	queue << [s, :string_start, id]
	queue << [t, :string_end, id]
end

(1..m).each do
	q = gets.to_i
	queue << [-q, :cut_point]
	queue << [q, :cut_point]
end

queue.sort!

i = 0
even = 0
odd = 0
parity = {}
x0 = nil
sum = 0
until queue.empty?
	x = queue[0][0]
	x0 ||= x
	sum += (x - x0) * (i.odd? ? odd : even)

	cut = false
	while !queue.empty? && queue[0][0] == x
		_, event, id = queue.shift
		case event
		when :cut_point
			cut = true
		when :string_start
			i.odd? ? (odd += 1) : (even += 1)
			parity[id] = i % 2
		when :string_end
			parity[id].odd? ? (odd -= 1) : (even -= 1)
		end
	end

	i += 1 if cut
	x0 = x
end

p sum