# 計算量 O(NC) = O(3 * 10 ** 6)

import sys

input = sys.stdin.readline

import numpy as np



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



# 入力

lst = [[0] * (10 ** 5 + 10) for _ in range(C + 1)]

lst_max = [[1] * (10 ** 5 + 10) for _ in range(C + 1)]



# lst = [[0] * (10) for _ in range(C + 1)]

# lst_max = [[1] * (10) for _ in range(C + 1)]



for _ in range(N):

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

    lst[c][s] += 1

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



lst = np.array(lst)

np.cumsum(lst, axis = 1, out = lst)

np.minimum(lst, lst_max, out = lst)

np.cumsum(lst, axis = 0, out = lst)



print((np.max(lst[-1])))
# 計算量 O(NC) = O(3 * 10 ** 6)

import sys

input = sys.stdin.readline

import numpy as np



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



# 入力

lst = [[0] * (10 ** 5 + 10) for _ in range(C + 1)]

# lst_max = [[1] * (10 ** 5 + 10) for _ in range(C + 1)]



# lst = [[0] * (10) for _ in range(C + 1)]

# lst_max = [[1] * (10) for _ in range(C + 1)]



for _ in range(N):

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

    lst[c][s] += 1

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



lst = np.array(lst)

np.cumsum(lst, axis = 1, out = lst)

np.minimum(lst, 1, out = lst)

np.cumsum(lst, axis = 0, out = lst)



print((np.max(lst[-1])))
# 計算量 O(NC) = O(3 * 10 ** 6)
import sys

input = sys.stdin.readline
import numpy as np

N, C = list(map(int, input().split()))
# 入力
lst = [[0] * (10**5 + 10) for _ in range(C + 1)]
lst_max = [[1] * (10**5 + 10) for _ in range(C + 1)]
# lst = [[0] * (10) for _ in range(C + 1)]
# lst_max = [[1] * (10) for _ in range(C + 1)]
for _ in range(N):
    s, t, c = list(map(int, input().split()))
    lst[c][s] += 1
    lst[c][t + 1] -= 1
lst = np.array(lst)
np.cumsum(lst, axis=1, out=lst)
np.minimum(lst, lst_max, out=lst)
np.cumsum(lst, axis=0, out=lst)
print((np.max(lst[-1])))

# 計算量 O(NC) = O(3 * 10 ** 6)
import sys

input = sys.stdin.readline
import numpy as np

N, C = list(map(int, input().split()))
# 入力
lst = [[0] * (10**5 + 10) for _ in range(C + 1)]
# lst_max = [[1] * (10 ** 5 + 10) for _ in range(C + 1)]
# lst = [[0] * (10) for _ in range(C + 1)]
# lst_max = [[1] * (10) for _ in range(C + 1)]
for _ in range(N):
    s, t, c = list(map(int, input().split()))
    lst[c][s] += 1
    lst[c][t + 1] -= 1
lst = np.array(lst)
np.cumsum(lst, axis=1, out=lst)
np.minimum(lst, 1, out=lst)
np.cumsum(lst, axis=0, out=lst)
print((np.max(lst[-1])))

-lst_max = [[1] * (10**5 + 10) for _ in range(C + 1)] +# lst_max = [[1] * (10 ** 5 + 10) for _ in range(C + 1)] -np.minimum(lst, lst_max, out=lst) +np.minimum(lst, 1, out=lst)