a = []
a = gets.split.map(&:to_i)
c = []
while s = gets
  c.push(s.split.map(&:to_i))
end

t_f = 0
t_l=1*10**5
#p c
for i in 0..a[1]-1
    if t_f<=c[i][0]
        t_f = c[i][0]
    end
    if t_l>=c[i][1]
        t_l = c[i][1]
    end
end
if t_l-t_f>=0
    puts t_l-t_f+1
else
    puts 0
end