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

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

MAX = 10**5

bucket = [[] for i in range(MAX+2)]

bucket2 = [set() for i in range(MAX+2)]

for s,t,c in src:

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

    bucket2[s].add(c)



imos = [0]*(MAX+2)



for s in range(MAX):

    for t,c in bucket[s]:

        imos[s-1] += 1

        if c in bucket2[t]:

            imos[t-1] -= 1

        else:

            imos[t] -= 1



ans = tmp = 0

for im in imos:

    tmp += im

    ans = max(ans, tmp)

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

STC = [tuple(map(int,input().split())) for i in range(N)]



cs = [[] for _ in range(30)]

for s,t,c in STC:

    cs[c-1].append((s,t))



imos = [0]*(100005)

for c in cs:

    c.sort(key=lambda x:x[0])

    pt = -1

    for s,t in c:

        if s==pt:

            imos[s] += 1

        else:

            imos[s-1] += 1

        imos[t] -= 1

        pt = t

for i in range(len(imos)-1):

    imos[i+1] += imos[i]

print((max(imos)))
N, C = list(map(int, input().split()))
src = [list(map(int, input().split())) for i in range(N)]
MAX = 10**5
bucket = [[] for i in range(MAX + 2)]
bucket2 = [set() for i in range(MAX + 2)]
for s, t, c in src:
    bucket[s].append((t, c))
    bucket2[s].add(c)
imos = [0] * (MAX + 2)
for s in range(MAX):
    for t, c in bucket[s]:
        imos[s - 1] += 1
        if c in bucket2[t]:
            imos[t - 1] -= 1
        else:
            imos[t] -= 1
ans = tmp = 0
for im in imos:
    tmp += im
    ans = max(ans, tmp)
print(ans)

N, C = list(map(int, input().split()))
STC = [tuple(map(int, input().split())) for i in range(N)]
cs = [[] for _ in range(30)]
for s, t, c in STC:
    cs[c - 1].append((s, t))
imos = [0] * (100005)
for c in cs:
    c.sort(key=lambda x: x[0])
    pt = -1
    for s, t in c:
        if s == pt:
            imos[s] += 1
        else:
            imos[s - 1] += 1
        imos[t] -= 1
        pt = t
for i in range(len(imos) - 1):
    imos[i + 1] += imos[i]
print((max(imos)))

-src = [list(map(int, input().split())) for i in range(N)] -MAX = 10**5 -bucket = [[] for i in range(MAX + 2)] -bucket2 = [set() for i in range(MAX + 2)] -for s, t, c in src: -    bucket[s].append((t, c)) -    bucket2[s].add(c) -imos = [0] * (MAX + 2) -for s in range(MAX): -    for t, c in bucket[s]: -        imos[s - 1] += 1 -        if c in bucket2[t]: -            imos[t - 1] -= 1 +STC = [tuple(map(int, input().split())) for i in range(N)] +cs = [[] for _ in range(30)] +for s, t, c in STC: +    cs[c - 1].append((s, t)) +imos = [0] * (100005) +for c in cs: +    c.sort(key=lambda x: x[0]) +    pt = -1 +    for s, t in c: +        if s == pt: +            imos[s] += 1 -            imos[t] -= 1 -ans = tmp = 0 -for im in imos: -    tmp += im -    ans = max(ans, tmp) -print(ans) +            imos[s - 1] += 1 +        imos[t] -= 1 +        pt = t +for i in range(len(imos) - 1): +    imos[i + 1] += imos[i] +print((max(imos)))