import qualified Data.Array.IO as A
import qualified Data.ByteString.Char8 as B
import Control.Monad
import Data.List
import Data.Maybe

main :: IO ()
main = do
    [n,_] <- map read . words <$> getLine :: IO [Int]
    qs <- scanl (+) 0 .
        map (\l -> sum $ map snd l) . groupBy (\a b -> fst a == fst b) . sort . concat 
        <$> replicateM n ( (\[a,b,_] -> [(a,1),(b+1,-1)]) .
        map (fst . fromJust . B.readInt) . B.words <$> B.getLine) :: IO [Int]
    print $ maximum qs
    
