import Data.List
import Data.Array.IO

main = do
  getLine
  chan <- sortBy compareC . map (readC . words) . lines <$> getContents
  let rr = newArray (0,200000) 0 :: IO (IOUArray Int Int)
  putStrLn . show . maximum =<< getElems =<< foldl reserve rr chan

readC :: [String] -> (Int, Int, Int)
readC s = ((read :: String -> Int) (s !! 0), (read :: String -> Int) (s !! 1), (read :: String -> Int) (s !! 2))

compareC :: (Int, Int, Int) -> (Int, Int, Int) -> Ordering
compareC (s1, t1, c1) (s2, t2, c2) = if c1 /= c2 then compare c1 c2
                                                 else compare s1 s2

equalC :: (Int, Int, Int) -> (Int, Int, Int) -> Bool
equalC (_, _, c1) (_, _, c2) = c1 == c2

isConnect :: (Int, Int, Int) -> (Int, Int, Int) -> Bool
isConnect (_, t, _) (s, _, _) = t == s

connect :: [(Int, Int, Int)] -> [(Int, Int, Int)] -> [(Int, Int, Int)]
connect x (y:_) = if equalC (last x) y && isConnect (last x) y
                    then (init x) ++ [connect' (last x) y]
                    else x ++ [y]

connect' :: (Int, Int, Int) -> (Int, Int, Int) -> (Int, Int, Int)
connect' (s, _, c) (_, t, _) = (s, t, c)

cut :: (Int, Int, Int) -> (Int, Int, Int)
cut (s, t, c) = (s * 2 - 1, t * 2, c)

reserv :: [Int] -> (Int, Int, Int) -> [Int]
reserv r (s, t, _) = (take s r) ++ (map (+1) (drop s . take (t+1) $ r)) ++ (drop (t+1) r)

reserve :: IO(IOUArray Int Int) -> (Int, Int, Int) -> IO (IOUArray Int Int)
reserve a (s, t, _) = foldl f a [s..t]

f :: IO (IOUArray Int Int) -> Int -> IO (IOUArray Int Int)
f a t = do
  aa <- a
  n <- readArray aa t
  writeArray aa t (n + 1)
  return aa
