a, b = gets.split(" ").map(&:to_i)
attrs = Array.new
ary = Array.new
i = 0

while line = $stdin.gets  
  aa, bb = line.chomp.split(" ")
  for cnt in aa..bb do
    ary << cnt
  end 
  i += 1
  break if i == b
end

#puts "#{ary}"
puts ary.select {|e| ary.count(e) == b}.uniq.size
