import sys

import numpy as np

input = sys.stdin.readline





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

tv_guide = np.zeros((c, 10**5+1), dtype=np.int)



for _ in range(n):

    s, t, c = [int(x)-1 for x in input().split()]

    tv_guide[c][s:t+1] = 1



ans = 0

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

    count = sum(tv_guide[:,time])

    ans = max(count, ans)



print(ans)
import sys

input = sys.stdin.readline





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

tv_guide = []

for _ in range(n):

    start, end, channel = list(map(int, input().split()))

    tv_guide.append([start, 1, channel-1])

    tv_guide.append([end, 0, channel-1])



tv_guide.sort(key=lambda x:(x[0], -x[1]))



channel_count = [0] * c

channel_set = set()

ans = 0

for time, on, channel in tv_guide:

    if on:

        channel_set.add(channel)

        channel_count[channel] += 1



    else:

        channel_count[channel] -= 1

        if channel_count[channel] == 0:

            channel_set.discard(channel)



    candidate = len(channel_set)

    if ans < candidate:

        ans = candidate



print(ans)
import sys
import numpy as np

input = sys.stdin.readline
n, c = list(map(int, input().split()))
tv_guide = np.zeros((c, 10**5 + 1), dtype=np.int)
for _ in range(n):
    s, t, c = [int(x) - 1 for x in input().split()]
    tv_guide[c][s : t + 1] = 1
ans = 0
for time in range(10**5 + 1):
    count = sum(tv_guide[:, time])
    ans = max(count, ans)
print(ans)

import sys

input = sys.stdin.readline
n, c = list(map(int, input().split()))
tv_guide = []
for _ in range(n):
    start, end, channel = list(map(int, input().split()))
    tv_guide.append([start, 1, channel - 1])
    tv_guide.append([end, 0, channel - 1])
tv_guide.sort(key=lambda x: (x[0], -x[1]))
channel_count = [0] * c
channel_set = set()
ans = 0
for time, on, channel in tv_guide:
    if on:
        channel_set.add(channel)
        channel_count[channel] += 1
    else:
        channel_count[channel] -= 1
        if channel_count[channel] == 0:
            channel_set.discard(channel)
    candidate = len(channel_set)
    if ans < candidate:
        ans = candidate
print(ans)

-import numpy as np -tv_guide = np.zeros((c, 10**5 + 1), dtype=np.int) +tv_guide = [] -    s, t, c = [int(x) - 1 for x in input().split()] -    tv_guide[c][s : t + 1] = 1 +    start, end, channel = list(map(int, input().split())) +    tv_guide.append([start, 1, channel - 1]) +    tv_guide.append([end, 0, channel - 1]) +tv_guide.sort(key=lambda x: (x[0], -x[1])) +channel_count = [0] * c +channel_set = set() -for time in range(10**5 + 1): -    count = sum(tv_guide[:, time]) -    ans = max(count, ans) +for time, on, channel in tv_guide: +    if on: +        channel_set.add(channel) +        channel_count[channel] += 1 +    else: +        channel_count[channel] -= 1 +        if channel_count[channel] == 0: +            channel_set.discard(channel) +    candidate = len(channel_set) +    if ans < candidate: +        ans = candidate