program ccc
implicit none

integer :: n, m, i, lmax, rmin, res
integer,allocatable,dimension(:) :: l, r

read*, n, m
allocate(l(m),r(m))
do i=1,m
read*, l(i), r(i)
end do

lmax=maxval(l)
rmin=minval(r)

res=rmin-lmax+1

if(res<0) write(*,'(i0)') res
write(*,'(i0)') res

end program