import sys

import numpy as np

input = sys.stdin.readline

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

a = np.zeros((C,10**5),dtype="int")

for _ in range(n):

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

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

print((max(np.sum(a,axis=0))))
import sys

input = sys.stdin.readline

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

ch = [[] for _ in range(C)]

tmax = 0

for _ in range(n):

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

  ch[c-1].append((s,t))

  tmax = max(tmax,t)

ch = [sorted(i,key= lambda x:x[0]) for i in ch]

imos = [0]*(tmax+2)

for i in ch:

  now = -1

  for ds,dt in i:

    if ds == now:

      imos[ds] +=1

    else:

      imos[ds-1] += 1

    imos[dt] -= 1

    now = dt

for i in range(tmax +1):

  imos[i+1] += imos[i]

print((max(imos)))
import sys
import numpy as np

input = sys.stdin.readline
n, C = list(map(int, input().split()))
a = np.zeros((C, 10**5), dtype="int")
for _ in range(n):
    s, t, c = list(map(int, input().split()))
    a[c - 1, s - 1 : t] = 1
print((max(np.sum(a, axis=0))))

import sys

input = sys.stdin.readline
n, C = list(map(int, input().split()))
ch = [[] for _ in range(C)]
tmax = 0
for _ in range(n):
    s, t, c = list(map(int, input().split()))
    ch[c - 1].append((s, t))
    tmax = max(tmax, t)
ch = [sorted(i, key=lambda x: x[0]) for i in ch]
imos = [0] * (tmax + 2)
for i in ch:
    now = -1
    for ds, dt in i:
        if ds == now:
            imos[ds] += 1
        else:
            imos[ds - 1] += 1
        imos[dt] -= 1
        now = dt
for i in range(tmax + 1):
    imos[i + 1] += imos[i]
print((max(imos)))

-import numpy as np -a = np.zeros((C, 10**5), dtype="int") +ch = [[] for _ in range(C)] +tmax = 0 -    a[c - 1, s - 1 : t] = 1 -print((max(np.sum(a, axis=0)))) +    ch[c - 1].append((s, t)) +    tmax = max(tmax, t) +ch = [sorted(i, key=lambda x: x[0]) for i in ch] +imos = [0] * (tmax + 2) +for i in ch: +    now = -1 +    for ds, dt in i: +        if ds == now: +            imos[ds] += 1 +        else: +            imos[ds - 1] += 1 +        imos[dt] -= 1 +        now = dt +for i in range(tmax + 1): +    imos[i + 1] += imos[i] +print((max(imos)))