object Main extends App {
	import scala.math._

	val NC = scala.io.StdIn.readLine.split(" ").map(_.toInt)

	val C = Array.ofDim[Int](NC(1), 100001)

	for(i<-0 until NC(0)){
		val temp = scala.io.StdIn.readLine.split(" ").map(_.toInt)

		for(j<-(temp(0)) to temp(1)){
			C(temp(2)-1)(j) = 1
		}
	}

	var count = 0
	var sum = 0

	for(i<-0 until 100000){
		sum = 0
		for(j<-0 until NC(1)){
			sum = sum + C(j)(i)
		}
		count = max(sum, count)
	}

	println(count)

	
}