import Data.Array.Unboxed
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]
    ns <- replicateM n ((\[a,b,c]->(a,b,c)) . map (fst . fromJust . B.readInt) . 
                        B.words <$> B.getLine) :: IO [(Int,Int,Int)]

    let x  = 100010
        ms = map (concatMap (\(a, b, _) -> [(a,1), (b,-1)]))
           $ groupBy (\(_, _, a) (_, _, b) -> a == b) ns :: [[(Int,Int)]]
        ls = map (
              f 0
            . map (sum . map snd)
            . groupBy (\a b -> fst a == fst b)
            . sort
            . (++ [(i,0)|i<-[1..x]])
            ) ms :: [[Int]]
        os = map (scanl (+) 0) ls

    -- mapM_ print os
    print . maximum $ foldr (zipWith (\n m -> n+m)) (head os) $ tail os

f :: Int -> [Int] -> [Int]
f n [] = [n]
f n (m:ms)
    | m < 0     = n : f m ms
    | otherwise = n+m : f 0 ms