program recording
  implicit none
  integer :: n, k, s, t, c, x(100001,30), i, j, m
  s = 0
  x = 0
  read(*,*) n, k
  do i = 1, n
    read(*,*) s, t, c
    x(s,c) = x(s,c) + 1
    x(t+1,c) = x(t+1,c) - 1
  end do
  do j = 1, k
    do i = 1, n
      x(i+1,j) = x(i+1,j) + x(i,j)
    end do
  end do
  m = 0
  do i = 1, n
    c = sum(x(i,:))
    if (m.lt.c) m = c
  end do
  write(*,'(i0)') m
  stop
end program recording