from itertools import accumulate

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

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



M = 10**5+1

merge = [[0]*(M+1) for _ in range(31)]

for i in range(N):

    s, t, c = STC[i]

    merge[c][s] += 1

    merge[c][t+1] -= 1

for c in range(31):

    merge[c] = list([int(bool(x)) for x in accumulate(merge[c])])



ans = []

for i in range(M+1):

    res = 0

    for j in range(31):

        res += merge[j][i]

    ans.append(res)

print((max(ans)))

from itertools import accumulate

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

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



M = 10**5+1

merge = [[0]*(M+1) for _ in range(31)]

for i in range(N):

    s, t, c = STC[i]

    #merge[c][s] += 1

    #merge[c][t+1] -= 1

    merge[c][s:t+1] = [1]*(t-s+1)

#for c in range(31):

#    merge[c] = list(map(lambda x: int(bool(x)), accumulate(merge[c])))

print((max(list(map(sum, list(zip(*merge)))))))



#ans = []

#for i in range(M+1):

#    res = 0

#    for j in range(31):

#        res += merge[j][i]

#    ans.append(res)

#print(max(ans))

from itertools import accumulate

N, C = list(map(int, input().split()))
STC = [list(map(int, input().split())) for _ in range(N)]
M = 10**5 + 1
merge = [[0] * (M + 1) for _ in range(31)]
for i in range(N):
    s, t, c = STC[i]
    merge[c][s] += 1
    merge[c][t + 1] -= 1
for c in range(31):
    merge[c] = list([int(bool(x)) for x in accumulate(merge[c])])
ans = []
for i in range(M + 1):
    res = 0
    for j in range(31):
        res += merge[j][i]
    ans.append(res)
print((max(ans)))

from itertools import accumulate

N, C = list(map(int, input().split()))
STC = [list(map(int, input().split())) for _ in range(N)]
M = 10**5 + 1
merge = [[0] * (M + 1) for _ in range(31)]
for i in range(N):
    s, t, c = STC[i]
    # merge[c][s] += 1
    # merge[c][t+1] -= 1
    merge[c][s : t + 1] = [1] * (t - s + 1)
# for c in range(31):
#    merge[c] = list(map(lambda x: int(bool(x)), accumulate(merge[c])))
print((max(list(map(sum, list(zip(*merge)))))))
# ans = []
# for i in range(M+1):
#    res = 0
#    for j in range(31):
#        res += merge[j][i]
#    ans.append(res)
# print(max(ans))

-    merge[c][s] += 1 -    merge[c][t + 1] -= 1 -for c in range(31): -    merge[c] = list([int(bool(x)) for x in accumulate(merge[c])]) -ans = [] -for i in range(M + 1): -    res = 0 -    for j in range(31): -        res += merge[j][i] -    ans.append(res) -print((max(ans))) +    # merge[c][s] += 1 +    # merge[c][t+1] -= 1 +    merge[c][s : t + 1] = [1] * (t - s + 1) +# for c in range(31): +#    merge[c] = list(map(lambda x: int(bool(x)), accumulate(merge[c]))) +print((max(list(map(sum, list(zip(*merge))))))) +# ans = [] +# for i in range(M+1): +#    res = 0 +#    for j in range(31): +#        res += merge[j][i] +#    ans.append(res) +# print(max(ans))