n,m = gets.split(" ").map(&:to_i)

min = []
max = []

m.times do 
  l,r = gets.split(" ").map(&:to_i)
  min.push(l)
  max.push(r)  
end

min.sort!
max.sort!

r = max.shift
l = min.pop

num = r - l + 1
puts num