import numpy as np

N, C = (int(x) for x in input().split())

R = [[0]*100000 for _ in range(C)] #R[c][t]:時刻t+1にチャンネルc+1を録画するのに必要な録画機の個数

R = np.array(R)

for _ in range(N):

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

    R[c-1,s-1:t] = 1

ans = max(sum(R))

print(ans)
import numpy as np



def main():

    with open(0) as f:

        N, C = list(map(int, f.readline().split()))

        Rec = [tuple(map(int, f.readline().split())) for _ in range(N)]

    

    time_line_by_channel = np.array([[0] * (10**5+1) for _ in range(C+1)])

    #チャンネルごとにタイムラインを作成

    for s, t, c in Rec:

        time_line_by_channel[c, s-1:t] = 1

    #タイムライン結合

    joined_timeline = np.sum(time_line_by_channel, axis=0)

    ans = max(joined_timeline)

    print(ans)



main()

import numpy as np

N, C = (int(x) for x in input().split())
R = [[0] * 100000 for _ in range(C)]  # R[c][t]:時刻t+1にチャンネルc+1を録画するのに必要な録画機の個数
R = np.array(R)
for _ in range(N):
    s, t, c = list(map(int, input().split()))
    R[c - 1, s - 1 : t] = 1
ans = max(sum(R))
print(ans)

import numpy as np


def main():
    with open(0) as f:
        N, C = list(map(int, f.readline().split()))
        Rec = [tuple(map(int, f.readline().split())) for _ in range(N)]
    time_line_by_channel = np.array([[0] * (10**5 + 1) for _ in range(C + 1)])
    # チャンネルごとにタイムラインを作成
    for s, t, c in Rec:
        time_line_by_channel[c, s - 1 : t] = 1
    # タイムライン結合
    joined_timeline = np.sum(time_line_by_channel, axis=0)
    ans = max(joined_timeline)
    print(ans)


main()

-N, C = (int(x) for x in input().split()) -R = [[0] * 100000 for _ in range(C)]  # R[c][t]:時刻t+1にチャンネルc+1を録画するのに必要な録画機の個数 -R = np.array(R) -for _ in range(N): -    s, t, c = list(map(int, input().split())) -    R[c - 1, s - 1 : t] = 1 -ans = max(sum(R)) -print(ans) + +def main(): +    with open(0) as f: +        N, C = list(map(int, f.readline().split())) +        Rec = [tuple(map(int, f.readline().split())) for _ in range(N)] +    time_line_by_channel = np.array([[0] * (10**5 + 1) for _ in range(C + 1)]) +    # チャンネルごとにタイムラインを作成 +    for s, t, c in Rec: +        time_line_by_channel[c, s - 1 : t] = 1 +    # タイムライン結合 +    joined_timeline = np.sum(time_line_by_channel, axis=0) +    ans = max(joined_timeline) +    print(ans) + + +main()