fun main(args: Array<String>) {
    val (n, cNum) = readLine()!!.split(" ").map(String::toInt)
    val table = Array(100000, { Array(cNum, {0}) })
    for (i in 0 until n) {
        val (s, t, c) = readLine()!!.split(" ").map(String::toInt)
        for (k in s -1 until t) {
            table[k][c - 1] = 1
        }
    }
    val ans = table.map { it.sum() }.max()
    println(ans)
}