import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, C = in.next().toInt
  val s = new Array[Int](N+1)
  val t = new Array[Int](N+1)
  val c = new Array[Int](N+1)

  for (i <- 1 to N) {
    val x, y, z = in.next().toInt
    s(i) = x
    t(i) = y
    c(i) = z
  }


  //
  val MAX = 1e5.toInt

  val dp = Array.ofDim[Int](31, (2 * MAX)+2)

  for (i <- 1 to N) {
    val l = s(i) * 2
    val r = t(i) * 2
    dp(c(i))(l - 1) += 1
    dp(c(i))(r + 1) -= 1
  }

  for(k <- 1 to 30) {
    for(i <- 1 to 2*MAX) {
      dp(k)(i) += dp(k)(i-1)
    }
  }

  var ans = 0
  for(i <- 1 to 2*MAX) {
    var tmp = 0
    for(k <- 1 to 30) {
      if (dp(k)(i) >= 1){
        tmp += 1
      }
    }
    ans = Math.max(ans, tmp)
  }

  println(ans)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
