N, C = list(map(int, input().split()))

M = 10 ** 5 * 2 + 5

T = [[0] * M for i in range(C)]

for i in range(N):

    s, t, c = list(map(int, input().split()))

    s = 2 * s - 1

    t = 2 * t

    c -= 1

    T[c][s] += 1

    T[c][t] -= 1



TT = [[0] * (2 * N) for i in range(C)]

for i in range(C):

    for j in range(1, M):

        T[i][j] += T[i][j - 1]



num = 0

for j in range(M):

    tmp = 0

    for i in range(C):

        if T[i][j] >= 1:

            tmp += 1



    num = max(tmp, num)

print(num)
N, C = list(map(int, input().split()))

M = 200005

rec = [[0] * M for i in range(C)]

for i in range(N):

    s, t, c = list(map(int, input().split()))

    rec[c - 1][2 * s - 1] += 1

    rec[c - 1][2 * t] -= 1



for j in range(C):

    for i in range(1, M):

        rec[j][i] += rec[j][i - 1]



num = 0

for j in range(M):

    tmp = 0

    for i in range(C):

        if rec[i][j] >= 1:

            tmp += 1

    num = max(tmp, num)



print(num)



N, C = list(map(int, input().split()))
M = 10**5 * 2 + 5
T = [[0] * M for i in range(C)]
for i in range(N):
    s, t, c = list(map(int, input().split()))
    s = 2 * s - 1
    t = 2 * t
    c -= 1
    T[c][s] += 1
    T[c][t] -= 1
TT = [[0] * (2 * N) for i in range(C)]
for i in range(C):
    for j in range(1, M):
        T[i][j] += T[i][j - 1]
num = 0
for j in range(M):
    tmp = 0
    for i in range(C):
        if T[i][j] >= 1:
            tmp += 1
    num = max(tmp, num)
print(num)

N, C = list(map(int, input().split()))
M = 200005
rec = [[0] * M for i in range(C)]
for i in range(N):
    s, t, c = list(map(int, input().split()))
    rec[c - 1][2 * s - 1] += 1
    rec[c - 1][2 * t] -= 1
for j in range(C):
    for i in range(1, M):
        rec[j][i] += rec[j][i - 1]
num = 0
for j in range(M):
    tmp = 0
    for i in range(C):
        if rec[i][j] >= 1:
            tmp += 1
    num = max(tmp, num)
print(num)

-M = 10**5 * 2 + 5 -T = [[0] * M for i in range(C)] +M = 200005 +rec = [[0] * M for i in range(C)] -    s = 2 * s - 1 -    t = 2 * t -    c -= 1 -    T[c][s] += 1 -    T[c][t] -= 1 -TT = [[0] * (2 * N) for i in range(C)] -for i in range(C): -    for j in range(1, M): -        T[i][j] += T[i][j - 1] +    rec[c - 1][2 * s - 1] += 1 +    rec[c - 1][2 * t] -= 1 +for j in range(C): +    for i in range(1, M): +        rec[j][i] += rec[j][i - 1] -        if T[i][j] >= 1: +        if rec[i][j] >= 1: