n, c = list(map(int, input().split()))



r = [[0 for i in range(c)] for j in range(100000)] 

for dummy in range(n): 

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

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

        r[j][c - 1] = 1 



ans = 0

for i in range(100000):

    if sum(r[i]) > ans:

        ans = sum(r[i]) 



print(ans)
n, c = list(map(int,input().split()))



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



for i in range(n):

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

	s -= 1

	ch -= 1

	for i in range(s,t):

		arr[i][ch] = 1



ans = 0



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

	ans = max(ans,sum(arr[i]))



print(ans)
n, c = list(map(int, input().split()))
r = [[0 for i in range(c)] for j in range(100000)]
for dummy in range(n):
    s, t, c = list(map(int, input().split()))
    for j in range(s - 1, t):
        r[j][c - 1] = 1
ans = 0
for i in range(100000):
    if sum(r[i]) > ans:
        ans = sum(r[i])
print(ans)

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

-r = [[0 for i in range(c)] for j in range(100000)] -for dummy in range(n): -    s, t, c = list(map(int, input().split())) -    for j in range(s - 1, t): -        r[j][c - 1] = 1 +arr = [[0 for i in range(c)] for j in range(10**5 + 1)] +for i in range(n): +    s, t, ch = list(map(int, input().split())) +    s -= 1 +    ch -= 1 +    for i in range(s, t): +        arr[i][ch] = 1 -for i in range(100000): -    if sum(r[i]) > ans: -        ans = sum(r[i]) +for i in range(10**5 + 1): +    ans = max(ans, sum(arr[i]))