import Data.List

reservation = replicate 200001 0

main = do
  getLine
  chan <- map (:[]) . sortBy compareC . map (readC . words) . lines <$> getContents
  putStrLn $ show . maximum . foldl reserve reservation . map cut . foldl1 connect $ chan

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

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

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

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

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

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

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

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