import Data.List
import Control.Monad

main = do
  [n, m] <- map read . words <$> getLine
  lrs <- map (map read . words) <$> replicateM m getLine :: IO [[Int]]
  print $ length $ solve n lrs

solve n lrs =
  let [l, r] = foldl1 (\[l, r] [l', r'] -> [max l l', min r r']) lrs
  in
      [(max l 1)..(min r n)]