import functools

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

T = [[0 for i in range(10 ** 5 + 1)] for j in range(C)]

for i in range(N):

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

  for j in range(s - 1, t):

    T[c - 1][j] = 1

ans = 0

for j in range(10 ** 5 + 1):

  r = 0

  for i in range(C):

    r += T[i][j]

  ans = max(ans, r)

print(ans)
import functools

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

P = [[0 for c in range(C)] for i in range(10 ** 5 + 1)]

T = 0

for i in range(N):

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

  T = max(t, T)

  for j in range(s - 1, t):

    P[j][c - 1] = 1

ans = 0

for p in P[:T + 1]:

  ans = max(sum(p), ans)

print(ans)
import functools

N, C = list(map(int, input().split()))
T = [[0 for i in range(10**5 + 1)] for j in range(C)]
for i in range(N):
    s, t, c = list(map(int, input().split()))
    for j in range(s - 1, t):
        T[c - 1][j] = 1
ans = 0
for j in range(10**5 + 1):
    r = 0
    for i in range(C):
        r += T[i][j]
    ans = max(ans, r)
print(ans)

import functools

N, C = list(map(int, input().split()))
P = [[0 for c in range(C)] for i in range(10**5 + 1)]
T = 0
for i in range(N):
    s, t, c = list(map(int, input().split()))
    T = max(t, T)
    for j in range(s - 1, t):
        P[j][c - 1] = 1
ans = 0
for p in P[: T + 1]:
    ans = max(sum(p), ans)
print(ans)

-T = [[0 for i in range(10**5 + 1)] for j in range(C)] +P = [[0 for c in range(C)] for i in range(10**5 + 1)] +T = 0 +    T = max(t, T) -        T[c - 1][j] = 1 +        P[j][c - 1] = 1 -for j in range(10**5 + 1): -    r = 0 -    for i in range(C): -        r += T[i][j] -    ans = max(ans, r) +for p in P[: T + 1]: +    ans = max(sum(p), ans)