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

stc = [[int(x) for x in input().split()] for _ in range(N)]



im = [[0] * (10**5 + 1) for _ in range(C + 1)]

for x in stc:

    s,t,c = x

    im[c][s] += 1

    im[c][t] -= 1



for c in range(1, C + 1):

    v = 0

    for i in range(1, 10**5 + 1):

        n = im[c][i]

        v += n

        if n > 0:

            im[c][i - 1] += 1

        im[c][i] = v

print((max([sum(x) for x in zip(*im[1:])])))
import operator

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

stc = [[int(x) for x in input().split()] for _ in range(N)]



united = []

pc,ps,pt = 0,0,0

for x in sorted(stc, key=operator.itemgetter(2,0,1)):

    s, t, c = x

    if c == pc and s == pt:

        united[-1][1] = t

    else:

        united.append([s, t, c])

    ps, pt, pc = x

cnt = [0] * (10**5 + 1)

for x in united:

    s,t,c = x

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

        cnt[i] += 1

print((max(cnt)))
N, C = list(map(int, input().split()))
stc = [[int(x) for x in input().split()] for _ in range(N)]
im = [[0] * (10**5 + 1) for _ in range(C + 1)]
for x in stc:
    s, t, c = x
    im[c][s] += 1
    im[c][t] -= 1
for c in range(1, C + 1):
    v = 0
    for i in range(1, 10**5 + 1):
        n = im[c][i]
        v += n
        if n > 0:
            im[c][i - 1] += 1
        im[c][i] = v
print((max([sum(x) for x in zip(*im[1:])])))

import operator

N, C = list(map(int, input().split()))
stc = [[int(x) for x in input().split()] for _ in range(N)]
united = []
pc, ps, pt = 0, 0, 0
for x in sorted(stc, key=operator.itemgetter(2, 0, 1)):
    s, t, c = x
    if c == pc and s == pt:
        united[-1][1] = t
    else:
        united.append([s, t, c])
    ps, pt, pc = x
cnt = [0] * (10**5 + 1)
for x in united:
    s, t, c = x
    for i in range(s - 1, t):
        cnt[i] += 1
print((max(cnt)))

+import operator + -im = [[0] * (10**5 + 1) for _ in range(C + 1)] -for x in stc: +united = [] +pc, ps, pt = 0, 0, 0 +for x in sorted(stc, key=operator.itemgetter(2, 0, 1)): -    im[c][s] += 1 -    im[c][t] -= 1 -for c in range(1, C + 1): -    v = 0 -    for i in range(1, 10**5 + 1): -        n = im[c][i] -        v += n -        if n > 0: -            im[c][i - 1] += 1 -        im[c][i] = v -print((max([sum(x) for x in zip(*im[1:])]))) +    if c == pc and s == pt: +        united[-1][1] = t +    else: +        united.append([s, t, c]) +    ps, pt, pc = x +cnt = [0] * (10**5 + 1) +for x in united: +    s, t, c = x +    for i in range(s - 1, t): +        cnt[i] += 1 +print((max(cnt)))