let n, m = Scanf.scanf " %d %d" @@ fun a b -> a, b
let csts = Array.init n @@ fun _ -> Scanf.scanf " %d %d %d" @@ fun s t c -> c, s, t
let acc = Array.make 100002 0
let _ = Array.(sort compare csts; fold_left (fun (c0, t0) (c, s, t) -> if c0 = c && t0 = s then acc.(t0 + 1) <- acc.(t0 + 1) + 1 else acc.(s) <- acc.(s) + 1; acc.(t + 1) <- acc.(t + 1) - 1; c, t) (0, 0) csts |> ignore; iteri (fun i a -> if i > 0 then acc.(i) <- acc.(i) + acc.(i - 1)) acc; fold_left max 0 acc) |> Printf.printf "%d\n"