n,m= gets.split(" ").map(&:to_i)
min = 0
max = n
m.times do
    l,r= gets.split(" ").map(&:to_i)
    if l > min
        min = l
    end
    if r < max
        max = r
    end
end

puts [max - min + 1,0].max