program main
  implicit none
  integer :: n, i, c, s, t, ch
  integer, allocatable :: cnt(:, :)
  read *, n, c
  allocate (cnt(c, 0:200000))
  cnt(:, :) = 0
  do i = 1, n
    read *, s, t, ch
    cnt(ch, 2 * s - 1) = cnt(ch, 2 * s - 1) + 1
    cnt(ch, 2 * t) = cnt(ch, 2 * t) - 1
  end do

  do i = 1, 200000
    cnt(:, i) = cnt(:, i) + cnt(:, i - 1)
  end do
  print "(i0)", maxval(sum(cnt, dim=1))
end program main
