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

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

time = [0 for i in range(10**5+1)]



program.sort()

program.sort(key = lambda x: x[2])

 

for i in range(1,n):

    if program[i][2]==program[i-1][2] and program[i][0]==program[i-1][1]:

        program[i][0] = program[i-1][0]

        program[i-1][0] = None

#print(program)

 

for i in range(n):

    if program[i][0] == None:

        continue

    time[program[i][0]-1] += 1

    time[program[i][1]] -= 1

 

count = 0

max_count = 0

 

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

    count += time[i]

    max_count = max(max_count,count)

 

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

ab = []

for _ in range(n):

    s, t, cha = (int(x) for x in input().split())

    ab.append([s, t, cha])



ab = sorted(ab, key=lambda x: x[0])

ab = sorted(ab, key=lambda x: x[2])



for i in range(1,n):

    if ab[i][0] == ab[i-1][1] and ab[i][2] == ab[i-1][2]:

        ab[i][0] = ab[i-1][0]

        ab[i-1][0] = -1



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



for i in range(n):

    if ab[i][0] == -1:

        continue

    time[ab[i][0]-1] += 1

    time[ab[i][1]] -= 1



ans = 0

memo = 0



for i in time:

    memo += i

    ans = max(ans,memo)



print(ans)
n, c = list(map(int, input().split()))
program = [list(map(int, input().split())) for i in range(n)]
time = [0 for i in range(10**5 + 1)]
program.sort()
program.sort(key=lambda x: x[2])
for i in range(1, n):
    if program[i][2] == program[i - 1][2] and program[i][0] == program[i - 1][1]:
        program[i][0] = program[i - 1][0]
        program[i - 1][0] = None
# print(program)
for i in range(n):
    if program[i][0] == None:
        continue
    time[program[i][0] - 1] += 1
    time[program[i][1]] -= 1
count = 0
max_count = 0
for i in range(10**5 + 1):
    count += time[i]
    max_count = max(max_count, count)
print(max_count)

n, c = list(map(int, input().split()))
ab = []
for _ in range(n):
    s, t, cha = (int(x) for x in input().split())
    ab.append([s, t, cha])
ab = sorted(ab, key=lambda x: x[0])
ab = sorted(ab, key=lambda x: x[2])
for i in range(1, n):
    if ab[i][0] == ab[i - 1][1] and ab[i][2] == ab[i - 1][2]:
        ab[i][0] = ab[i - 1][0]
        ab[i - 1][0] = -1
time = [0] * (10**5 + 1)
for i in range(n):
    if ab[i][0] == -1:
        continue
    time[ab[i][0] - 1] += 1
    time[ab[i][1]] -= 1
ans = 0
memo = 0
for i in time:
    memo += i
    ans = max(ans, memo)
print(ans)

-program = [list(map(int, input().split())) for i in range(n)] -time = [0 for i in range(10**5 + 1)] -program.sort() -program.sort(key=lambda x: x[2]) +ab = [] +for _ in range(n): +    s, t, cha = (int(x) for x in input().split()) +    ab.append([s, t, cha]) +ab = sorted(ab, key=lambda x: x[0]) +ab = sorted(ab, key=lambda x: x[2]) -    if program[i][2] == program[i - 1][2] and program[i][0] == program[i - 1][1]: -        program[i][0] = program[i - 1][0] -        program[i - 1][0] = None -# print(program) +    if ab[i][0] == ab[i - 1][1] and ab[i][2] == ab[i - 1][2]: +        ab[i][0] = ab[i - 1][0] +        ab[i - 1][0] = -1 +time = [0] * (10**5 + 1) -    if program[i][0] == None: +    if ab[i][0] == -1: -    time[program[i][0] - 1] += 1 -    time[program[i][1]] -= 1 -count = 0 -max_count = 0 -for i in range(10**5 + 1): -    count += time[i] -    max_count = max(max_count, count) -print(max_count) +    time[ab[i][0] - 1] += 1 +    time[ab[i][1]] -= 1 +ans = 0 +memo = 0 +for i in time: +    memo += i +    ans = max(ans, memo) +print(ans)