nm = gets.chomp.split(" ")
n = nm[0].to_i
m = nm[1].to_i

gate_ranges = []
m.times.each do
  lr = gets.chomp.split(" ")
  gate_ranges << ((lr[0].to_i)..(lr[1].to_i))
end

gate_idxs = gate_ranges.map {|range| range.to_a}.flatten
ans_idxs = gate_idxs.inject(Hash.new(0)){|h, i| h[i] += 1; h }.reject{|k, v| v != m }.keys

puts ans_idxs.length