import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (_ : m : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  lrs <- sequence . replicate m $ unsafeListToTuple . map unsafeSignedDecimal . T.words <$> T.getLine :: IO [(Int, Int)]
  let
    (l, r) = ((,) <$> maximum . fst <*> minimum . snd) . unzip $ lrs
  print $ max 0 (r - l + 1)

unsafeListToTuple :: [Int] -> (Int, Int)
unsafeListToTuple (x : y : _) = (x, y)

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n
