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



tt = [[0] * (2 * 10 ** 5 + 1) for _ in range(30)]

for _ in range(N):

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

    ttc = tt[c - 1]

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

        ttc[i] = 1



ct = [0] * (2 * 10 ** 5 + 1)

for i in range(30):

    tti = tt[i]

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

        ct[j] += tti[j]



print((max(ct)))

from operator import itemgetter



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

stc = [list(map(int, input().split())) for _ in range(N)]

stc.sort(key=itemgetter(2, 0))



cs = [0] * (10 ** 5 * 2 + 1)

pc = -1

for s, t, c in stc:

    if pc != c:

        pt = -1

        pc = c

    if pt == s:

        cs[s * 2] += 1

    else:

        cs[s * 2 - 1] += 1

    cs[t * 2] -= 1

    pt = t



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

    cs[i] += cs[i - 1]



print((max(cs)))

N, C = list(map(int, input().split()))
tt = [[0] * (2 * 10**5 + 1) for _ in range(30)]
for _ in range(N):
    s, t, c = list(map(int, input().split()))
    ttc = tt[c - 1]
    for i in range(s * 2 - 1, t * 2):
        ttc[i] = 1
ct = [0] * (2 * 10**5 + 1)
for i in range(30):
    tti = tt[i]
    for j in range(2 * 10**5 + 1):
        ct[j] += tti[j]
print((max(ct)))

from operator import itemgetter

N, C = list(map(int, input().split()))
stc = [list(map(int, input().split())) for _ in range(N)]
stc.sort(key=itemgetter(2, 0))
cs = [0] * (10**5 * 2 + 1)
pc = -1
for s, t, c in stc:
    if pc != c:
        pt = -1
        pc = c
    if pt == s:
        cs[s * 2] += 1
    else:
        cs[s * 2 - 1] += 1
    cs[t * 2] -= 1
    pt = t
for i in range(1, 10**5 * 2 + 1):
    cs[i] += cs[i - 1]
print((max(cs)))

+from operator import itemgetter + -tt = [[0] * (2 * 10**5 + 1) for _ in range(30)] -for _ in range(N): -    s, t, c = list(map(int, input().split())) -    ttc = tt[c - 1] -    for i in range(s * 2 - 1, t * 2): -        ttc[i] = 1 -ct = [0] * (2 * 10**5 + 1) -for i in range(30): -    tti = tt[i] -    for j in range(2 * 10**5 + 1): -        ct[j] += tti[j] -print((max(ct))) +stc = [list(map(int, input().split())) for _ in range(N)] +stc.sort(key=itemgetter(2, 0)) +cs = [0] * (10**5 * 2 + 1) +pc = -1 +for s, t, c in stc: +    if pc != c: +        pt = -1 +        pc = c +    if pt == s: +        cs[s * 2] += 1 +    else: +        cs[s * 2 - 1] += 1 +    cs[t * 2] -= 1 +    pt = t +for i in range(1, 10**5 * 2 + 1): +    cs[i] += cs[i - 1] +print((max(cs)))