      PROGRAM piyo
      IMPLICIT NONE
      integer(16) :: n,m,lMax,rMin,i
      integer(16),allocatable :: l(:),r(:)
      
      read*,n,m
      allocate( l(m),r(m) )
      do i = 1,m
        read*,l(i),r(i)
      end do
      
      
      
      rMin = minval( r )
      lMax = maxval( l )
      
      
      print*,rMin - lMax + 1
      
      
      
      
      END PROGRAM