CodeEff/ECCO huggingface dataset:
# Original solution
N, C = list(map(int, input().split()))
programs = [[0 for _ in range(C)] for _ in range(2*10**5)]
for _ in range(N):
    s, t, c = list(map(int, input().split()))
    for i in range(2*s-1, 2*t):
        programs[i][c-1] = 1
ret = 0
for i in range(2*10**5):
    ret = max(ret, sum(programs[i]))
print(ret)


# Optimized solution
N, C = list(map(int, input().split()))
programs = [[0 for _ in range(C)] for _ in range(10**5)]
for _ in range(N):
    s, t, c = list(map(int, input().split()))
    for i in range(s-1, t):
        programs[i][c-1] = 1
ret = 0
for i in range(10**5):
    ret = max(ret, sum(programs[i]))
print(ret)
# Original solution

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

    #　各時間各チャンネルで録画機が動いてるかどうか
    R = [[0]*(10**5) for _ in range(C)]

    for _ in range(N):
        s,t,c = list(map(int, input().split()))
        #チャンネルｃをｓからｔまで録画、ｓの0.5秒前から録画機を使うのでs-1始まりにする
        R[c-1][s-1:t] = [1] * (t-(s-1))

    ans = 0
    for t in range(10**5):
        cnt = 0
        #時刻ごとにそれぞれのチャンネルで録画機を使ってるかどうか数え上げる
        for ch in range(C):
            if R[ch][t] == 1: cnt += 1

        ans = max(ans, cnt)

    print(ans)

if __name__ == "__main__":
    main()

# Optimized solution

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

    #　各時間各チャンネルで録画機が動いてるかどうか
    R = [[0]*(10**5) for _ in range(C)]

    for _ in range(N):
        s,t,c = list(map(int, input().split()))
        #チャンネルｃをｓからｔまで録画、ｓの0.5秒前から録画機を使うのでs-1始まりにする
        R[c-1][s-1:t] = [1] * (t-(s-1))

    ans = max(list(map(sum, list(zip(*R)))))
    """
    ans = 0
    for t in range(10**5):
        cnt = 0
        #時刻ごとにそれぞれのチャンネルで録画機を使ってるかどうか数え上げる
        for ch in range(C):
            if R[ch][t] == 1: cnt += 1

        ans = max(ans, cnt)
    """
    print(ans)

if __name__ == "__main__":
    main()
# Original solution
N,C = list(map(int,input().split()))
tv_times = [[int(j) for j in input().split()] for i in range(N)]

channells = {}
for i in range(C+1):
    channells[i] = []
max_end = -1

for i in range(N):
    s,g,c = tv_times[i]
    max_end = max(max_end,g)
    channells[c] += [s,g]

tv_times = []
f = [0 for i in range(max_end+1)]
for cha in list(channells.keys()):
    remove_list = []
    time = channells[cha]
    time.sort()
    for i in range(1,len(time)-1):
        if time[i] == time[i+1]:
            remove_list.append(time[i])
    for i in range(len(remove_list)):
        for j in range(2):
            time.remove(remove_list[i])

    for i in range(len(time)//2):
        f[max(time[2*i]-1,0)] += 1
        f[time[2*i+1]] -= 1

ans = -1
for i in range(1,max_end+1):
    f[i] += f[i-1]
    if ans < f[i]:
        ans = f[i]

# print(f)
print(ans)


# Optimized solution
N,C = list(map(int,input().split()))
tv_times = [[int(j) for j in input().split()] for i in range(N)]

channells = {}
for i in range(C+1):
    channells[i] = []
max_end = -1

for i in range(N):
    s,g,c = tv_times[i]
    max_end = max(max_end,g)
    channells[c] += [s,g]

tv_times = []
f = [0 for i in range(max_end+1)]
for cha in list(channells.keys()):
    remove_list = []
    time = channells[cha]
    time.sort()
    for i in range(1,len(time)-1):
        if time[i] == time[i+1]:
            remove_list.append(time[i])
    time = list(set(time)-set(remove_list))
    time.sort()
    for i in range(len(time)//2):
        f[max(time[2*i]-1,0)] += 1
        f[time[2*i+1]] -= 1
ans = -1
for i in range(1,max_end+1):
    f[i] += f[i-1]
    if ans < f[i]:
        ans = f[i]

print(ans)
# Original solution
N, C = list(map(int, input().split()))
TV = [[0]*(2*10**5) for i in range(C)]

for i in range(N):
    s, t, c = list(map(int, input().split()))
    TV[c-1][2*s-2] += 1
    TV[c-1][2*t-1] -= 1

for i in range(C):
    for j in range(1, 2*10**5):
        TV[i][j] = TV[i][j]+TV[i][j-1]

for i in range(C):
    for j in range(1, 2*10**5):
        TV[i][j] = min(1, TV[i][j])

ans = 0
for i in range(2*10**5):
    tmp = 0
    for j in range(C):
        tmp += TV[j][i]
    ans = max(ans, tmp)
print(ans)


# Optimized solution
from itertools import accumulate
N, C = list(map(int, input().split()))
G = [[0] * (10 ** 5 + 1) for i in range(C)]
for i in range(N):
    s, t, c = list(map(int, input().split()))
    c = c - 1
    G[c][s - 1] += 1
    G[c][t] -= 1

for i in range(C):
    G[i] = list(accumulate(G[i]))

ans = 0
for i in range(10 ** 5 + 1):
    tmp = 0
    for c in range(C):
        tmp += min(1, G[c][i])
    ans = max(ans, tmp)

print(ans)
# Original solution
n, c = list(map(int, input().split()))
stc = []
for _ in range(n):
  stc.append(tuple(map(int, input().split())))

sm = [0 for _ in range(2 * (pow(10, 5) + 1))]
for _c in range(c):
  tt = [0 for _ in range(2 * (pow(10, 5) + 1))]
  for s, t, c in stc:
    if c == _c + 1:
      tt[s * 2 - 1] += 1
      tt[t * 2] -= 1
  for i in range(1, len(tt)):
    tt[i] += tt[i-1]
  for i in range(len(sm)):
    if tt[i] > 0:
      sm[i] += 1

print((max(sm)))


# Optimized solution
import sys
input = sys.stdin.readline

from heapq import heappop, heappush

def main():
  n, c = list(map(int, input().split()))
  stc = []
  for _ in range(n):
    stc.append(tuple(map(int, input().split())))
  stc = list(sorted(stc, key=lambda x: (x[2], x[0])))
  restc = []
  prev = stc[0]
  for _stc in stc[1:]:
    if prev[2] == _stc[2] and prev[1] == _stc[0]:
      prev = (prev[0], _stc[1], prev[2])
    else:
      restc.append(prev)
      prev = _stc
  restc.append(prev)

  ans = 0
  th = []
  for _stc in sorted(restc):
    if not th:
      heappush(th, _stc[1])
      if ans == 0:
        ans = 1
    else:
      _th = heappop(th)
      if _th < _stc[0]:
        heappush(th, _stc[1])
      else:
        heappush(th, _th)
        heappush(th, _stc[1])
        ans = max(ans, len(th))
  print(ans)


if __name__ == '__main__':
  main()
# Original solution
def main():
    from itertools import accumulate
    n, c, *stc = list(map(int, open(0).read().split()))
    table = [0] * 2 * (10 ** 5 + 1)
    m = list(zip(stc[::3], stc[1::3], stc[2::3]))
    m.sort(key=lambda a: (a[2], a[0], a[1]))

    ch_ = 0
    t_ = 0
    for s, t, ch in m:
        if ch != ch_:
            ch_ = ch
            t_ = 0
        if t_ == 2 * s:
            table[t_ + 1] += 1
        else:
            table[2 * s - 1] += 1

        table[2 * t + 1] -= 1
        t_ = 2 * t

    *x, = accumulate(table)
    ans = max(x)

    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    from itertools import accumulate
    n, c, *stc = list(map(int, open(0).read().split()))
    table = [0] * (10 ** 5 + 2)
    m = list(zip(stc[::3], stc[1::3], stc[2::3]))
    m.sort(key=lambda a: (a[2], a[0], a[1]))

    ch_ = 0
    t_ = 0
    for s, t, ch in m:
        if ch != ch_:
            ch_ = ch
            t_ = 0
        if t_ == s:
            table[t_ + 1] += 1
        else:
            table[s] += 1

        table[t + 1] -= 1
        t_ = t

    *x, = accumulate(table)
    ans = max(x)

    print(ans)


if __name__ == '__main__':
    main()
# Original solution
def main():
    from itertools import accumulate
    n, c, *stc = list(map(int, open(0).read().split()))
    table = [0] * (10 ** 5 + 2)
    m = list(zip(stc[::3], stc[1::3], stc[2::3]))
    m.sort(key=lambda a: (a[2], a[0], a[1]))

    ch_ = 0
    t_ = 0
    for s, t, ch in m:
        if ch != ch_:
            ch_ = ch
            t_ = 0
        if t_ == s:
            table[t_ + 1] += 1
        else:
            table[s] += 1

        table[t + 1] -= 1
        t_ = t

    *x, = accumulate(table)
    ans = max(x)

    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    from itertools import accumulate
    n, c, *stc = list(map(int, open(0).read().split()))
    table = [0] * (10 ** 5 + 2)
    m = sorted(list(zip(*[iter(stc)] * 3)), key=lambda a: (a[2], a[0], a[1]))

    ch_ = 0
    t_ = 0
    for s, t, ch in m:
        if ch != ch_:
            ch_ = ch
            t_ = 0
        if t_ == s:
            table[t_ + 1] += 1
        else:
            table[s] += 1

        table[t + 1] -= 1
        t_ = t

    *x, = accumulate(table)
    ans = max(x)

    print(ans)


if __name__ == '__main__':
    main()
# Original solution
def main():
    from itertools import accumulate
    n, c, *stc = list(map(int, open(0).read().split()))
    table = [0] * (10 ** 5 + 2)
    m = sorted(list(zip(*[iter(stc)] * 3)), key=lambda a: (a[2], a[0], a[1]))

    ch_ = 0
    t_ = 0
    for s, t, ch in m:
        if ch != ch_:
            ch_ = ch
            t_ = 0
        if t_ == s:
            table[t_ + 1] += 1
        else:
            table[s] += 1

        table[t + 1] -= 1
        t_ = t

    *x, = accumulate(table)
    ans = max(x)

    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    from itertools import accumulate
    n, c, *stc = list(map(int, open(0).read().split()))
    table = [0] * (10 ** 5 + 2)
    m = sorted(list(zip(*[iter(stc)] * 3)), key=lambda a: (a[2], a[0]))

    ch_ = 0
    t_ = 0
    for s, t, ch in m:
        if ch != ch_:
            ch_ = ch
            t_ = 0
        if t_ == s:
            table[t_ + 1] += 1
        else:
            table[s] += 1

        table[t + 1] -= 1
        t_ = t

    *x, = accumulate(table)
    ans = max(x)

    print(ans)


if __name__ == '__main__':
    main()
# Original solution
n, c = list(map(int, input().split()))
cnt = [[0 for _ in range(c)] for j in range(10 ** 5 + 1)]
cnt_sum = [0] * (10 ** 5 + 1)
for _ in range(n):
    s, t, _c = list(map(int, input().split()))
    cnt[s - 1][_c - 1] += 1
    cnt[t][_c - 1] -= 1
for i in range(1, 10 ** 5 + 1):
    for j in range(c):
        cnt[i][j] += cnt[i - 1][j]
for i in range(10 ** 5 + 1):
    for j in range(c):
        cnt_sum[i] += (cnt[i][j] >= 1)
print((max(cnt_sum)))

# Optimized solution
n, c = list(map(int, input().split()))
cnt = [[0 for _ in range(10 ** 5 + 1)] for _ in range(c)]

for _ in range(n):
    s, t, _c = list(map(int, input().split()))
    for j in range(s, t + 1):
        cnt[_c - 1][j] = 1
ans = 0
for i in range(10 ** 5 + 1):
    ans = max(ans, sum(cnt[j][i] for j in range(c)))
print(ans)
# Original solution
N,C=list(map(int,input().split()))
from collections import defaultdict
cannel={i:[] for i in range(1,1+C)}
check=[tuple(map(int,input().split())) for i in range(N)]
check.sort(key=lambda x:x[0])
for x in check:
    s,t,c=x
    if cannel[c]==[]:
        cannel[c].append((max(0,s-1),t))
    elif s-cannel[c][-1][1]<=1:
        cannel[c][-1]=(cannel[c][-1][0],t)
    else:
        cannel[c].append((max(0,s-1),t))
start=defaultdict(int)
end=defaultdict(int)
for c in range(1,1+C):
    for x in cannel[c]:
        start[x[0]]+=1
        end[x[1]]+=1
ans=0
now=0
for i in range(10**5+1):
    now+=start[i]-end[i]
    ans=max(ans,now)
print(ans)

# Optimized solution
N,C=list(map(int,input().split()))
from collections import defaultdict
Cbef=defaultdict(int)
time=defaultdict(int)
TV=[tuple(map(int,input().split())) for i in range(N)]
TV.sort(key=lambda x:x[0])
for s,t,c in TV:
    if Cbef[c]==s:
        time[s]+=1
        time[t]-=1
        Cbef[c]=t
    else:
        time[s-1]+=1
        time[t]-=1
        Cbef[c]=t
ans=0
now=time[0]
ans=now
for i in range(1,10**5+1):
    now+=time[i]
    ans=max(ans,now)
print(ans)
# Original solution
n, c = list(map(int, input().split()))

r = [[0 for i in range(c)] for j in range(100000)]  # テレビ局の番組表
for dummy in range(n):  # 入力
    s, t, c = list(map(int, input().split()))
    for j in range(s - 1, t):
        r[j][c - 1] = 1  # 放送中なら1

ans = 0
for i in range(100000):
    if sum(r[i]) > ans:
        ans = sum(r[i])  # 同時に放送されている番組の最大数

print(ans)

# Optimized solution
N, C = list(map(int, input().split()))
r = [[0] * C for _ in range(10 ** 5)]
for _ in range(N):
    s, t, c = list(map(int, input().split()))
    for i in range(s - 1, t):
        r[i][c - 1] = 1
ans = 0
for t in r:
    sum_t = sum(t)
    if sum_t > ans:
        ans = sum_t

print(ans)
# Original solution
#!/usr/bin/env python3
#ABC80 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n,C = LI()
stc = [LI() for _ in range(n)]
L = []
for i in range(C):
    lst = []
    for j in range(n):
        s,t,c = stc[j]
        if i+1 == c:
            lst.append([s,t])
    lst.sort(key = itemgetter(0))
    lst2 = []
    j = 0
    while j < len(lst):
        if j < len(lst)-1:
            if lst[j][1] == lst[j+1][0]:
                lst2.append((lst[j][0],lst[j+1][1]))
                j += 2
                continue

        lst2.append(tuple(lst[j]))
        j += 1
    L.append(lst2)
x = [[0]*100002 for _ in range(C)]
for i in range(C):
    for j,k in L[i]:
        x[i][j] += 1
        x[i][k+1] -= 1
    x[i] = list(accumulate(x[i]))
ans = 0
for i in range(1,10**5+1):
    s = 0
    for j in range(C):
        if x[j][i] == 1:
            s += 1
    ans = max(ans,s)
print(ans)


# Optimized solution
#!/usr/bin/env python3
#ABC80 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,C = LI()
cha = [[] for _ in range(C)]
ans = 0
lst = [0]*(10**5+2)
for _ in range(n):
    s,t,c = LI()
    cha[c-1].append([s,t])
for i in range(C):
    if len(cha[i]) == 0:
        continue
    cha[i].sort(key = itemgetter(0))
    s,t = cha[i][0]
    tmp = []
    for j in range(1,len(cha[i])):
        if t == cha[i][j][0]:
            t = cha[i][j][1]
        else:
            tmp.append([s,t])
            s,t = cha[i][j]
    tmp.append([s,t])
    for i,j in tmp:
        lst[i] += 1
        lst[j+1] -= 1
lst = list(accumulate(lst))
print((max(lst)))
# Original solution
import sys
import math
from itertools import accumulate as acc

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


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

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

for i in range(N):
    s,t,c=list(map(int,input().split()))
    recs,rect=a[c][s],a[c][t]
    if recs==0 and rect==0:
        rec[s-1]+=1
        rec[t]-=1
    elif recs==0 and rect==1:
        rec[s-1]+=1
        rec[t-1]-=1
    elif recs==1 and rect==0:
        rec[s]+=1
        rec[t]-=1
    elif recs==1 and rect==1:
        rec[s]+=1
        rec[t-1]-=1

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

tmp=0
ans=0
for i in range(10**5):
    tmp+=rec[i]
    ans=max(tmp,ans)
print(ans)

# Optimized solution
import sys
import math
from itertools import accumulate as acc

input=sys.stdin.readline

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


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

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

for i in range(N):
    s,t,c=list(map(int,input().split()))
    recs,rect=a[c][s],a[c][t]
    if recs==0 and rect==0:
        rec[s-1]+=1
        rec[t]-=1
    elif recs==0 and rect==1:
        rec[s-1]+=1
        rec[t-1]-=1
    elif recs==1 and rect==0:
        rec[s]+=1
        rec[t]-=1
    elif recs==1 and rect==1:
        rec[s]+=1
        rec[t-1]-=1

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

tmp=0
ans=0
for i in range(10**5):
    tmp+=rec[i]
    ans=max(tmp,ans)
print(ans)
# Original solution
import sys
import math
from itertools import accumulate as acc

input=sys.stdin.readline

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


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

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

for i in range(N):
    s,t,c=list(map(int,input().split()))
    recs,rect=a[c][s],a[c][t]
    if recs==0 and rect==0:
        rec[s-1]+=1
        rec[t]-=1
    elif recs==0 and rect==1:
        rec[s-1]+=1
        rec[t-1]-=1
    elif recs==1 and rect==0:
        rec[s]+=1
        rec[t]-=1
    elif recs==1 and rect==1:
        rec[s]+=1
        rec[t-1]-=1

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

tmp=0
ans=0
for i in range(10**5):
    tmp+=rec[i]
    ans=max(tmp,ans)
print(ans)

# Optimized solution
import sys
import math
from itertools import accumulate as acc

input=sys.stdin.readline

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


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

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

for i in range(N):
    s,t,c=list(map(int,input().split()))
    recs,rect=a[c][s],a[c][t]
    if recs==0 and rect==0:
        rec[s-1]+=1
        rec[t]-=1
    elif recs==0 and rect==1:
        rec[s-1]+=1
        rec[t-1]-=1
    elif recs==1 and rect==0:
        rec[s]+=1
        rec[t]-=1
    elif recs==1 and rect==1:
        rec[s]+=1
        rec[t-1]-=1

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

print((max(list(acc(rec)))))
# Original solution
N_C = list(map(int, input().split()))
s_t_c = []
for i in range(N_C[0]):
    s_t_c.append(list(map(int, input().split())))

max_number = 0
for j in range(10 ** 5):
    number = 0
    for k in range(N_C[0]):
        if s_t_c[k][0] <= j - 1 and s_t_c[k][1] >= j:
            number = number + 1
        if s_t_c[k][0] <= j and s_t_c[k][1] >= j + 1:
            number = number + 1
        if s_t_c[k][0] <= j - 1 and s_t_c[k][1] >= j + 1:
            number = number - 1
    max_number = max(max_number, number)

print(max_number)

# Optimized solution
n, C = list(map(int, input().split()))
time = 0
stc = []
for i in range(n):
    temp = list(map(int, input().split()))
    time = max(time, temp[1])
    stc.append(temp)
tv = [[0 for i in range(C)] for i in range(time + 1)]
for i in stc:
    s, t, c = i[0], i[1], i[2]
    for j in range(s, t + 1):
        tv[j][c - 1] = 1
ans = 0
for i in tv:
    ans = max(ans, sum(i))
print(ans)
# Original solution
N, C = list(map(int, input().split()))
M = 10 ** 5 * 2 + 5
T = [[0] * M for i in range(C)]
for i in range(N):
    s, t, c = list(map(int, input().split()))
    s = 2 * s - 1
    t = 2 * t
    c -= 1
    T[c][s] += 1
    T[c][t] -= 1

TT = [[0] * (2 * N) for i in range(C)]
for i in range(C):
    for j in range(1, M):
        T[i][j] += T[i][j - 1]

num = 0
for j in range(M):
    tmp = 0
    for i in range(C):
        if T[i][j] >= 1:
            tmp += 1

    num = max(tmp, num)
print(num)

# Optimized solution
N, C = list(map(int, input().split()))
M = 200005
rec = [[0] * M for i in range(C)]
for i in range(N):
    s, t, c = list(map(int, input().split()))
    rec[c - 1][2 * s - 1] += 1
    rec[c - 1][2 * t] -= 1

for j in range(C):
    for i in range(1, M):
        rec[j][i] += rec[j][i - 1]

num = 0
for j in range(M):
    tmp = 0
    for i in range(C):
        if rec[i][j] >= 1:
            tmp += 1
    num = max(tmp, num)

print(num)
# Original solution
T_MAX = 10**5
n, nc = list(map(int, input().split()))
stc = [list(map(int, input().split())) for _ in range(n)]

nrecs = [0]*(2*T_MAX+1)
for c in range(1, nc+1):
    rec = [0]*(2*T_MAX+1)
    for i in range(n):
        if stc[i][2] == c:
            rec[stc[i][0]*2-1] += 1
            rec[stc[i][1]*2] -= 1
    for i in range(1, 2*T_MAX+1):
        rec[i] += rec[i-1]
    for i in range(2*T_MAX+1):
        if rec[i] > 0:
            nrecs[i] += 1
    
print((max(nrecs)))


# Optimized solution
T_MAX = 10**5
n, nc = list(map(int, input().split()))
stc = [list(map(int, input().split())) for _ in range(n)]

recs = [[0]*(T_MAX+1) for c in range(nc+1)]
for s, t, c in stc:
    recs[c][s-1:t] = [1]*(t-s+1)

ans = max(list(map(sum, list(zip(*recs)))))
print(ans)
# Original solution
N,C=list(map(int,input().split()))
Time=[[0]*(10**5+1)]*C
for i in range(N):
  s,t,c=list(map(int,input().split()))
  T_c=list(Time[c-1])
  T_c[s-1:t]=[1]*(t-s+1)
  Time[c-1]=list(T_c)
Times=max(list(map(sum,list(zip(*Time)))))
print(Times)

# Optimized solution
N,C=list(map(int,input().split()))
Time=[[0]*(10**5+1) for c in range(C)]
for i in range(N):
  s,t,c=list(map(int,input().split()))  
  Time[c-1][s-1:t] = [1]*(t-s+1)
Times=max(list(map(sum,list(zip(*Time)))))
print(Times)
# Original solution
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in list(inspect.currentframe().f_back.f_locals.items())
    }
    print((', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args)))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    N, C = li_input()

    A = [[0] * 100001 for _ in range(C)]
    S = [0] * 100001

    for i in range(N):
        s, t, c = li_input()

        for j in range(s, t):
            A[c - 1][j] += 1

    for a in A:
        for i in range(1, len(a)):
            if a[i] == 1 or (i != len(a) - 1 and a[i + 1]) == 1:
                S[i] += 1

    print((max(S)))


main()


# Optimized solution
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in list(inspect.currentframe().f_back.f_locals.items())
    }
    print((', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args)))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    N, C = li_input()

    A = [[0] * 100001 for _ in range(C)]
    S = [0] * 100001

    for i in range(N):
        s, t, c = li_input()

        for j in range(s - 1, t):
            A[c - 1][j] += 1

    for a in A:
        for i in range(1, len(a)):
            if a[i]:
                S[i] += 1

    print((max(S)))


main()
# Original solution
N,C = list(map(int,input().split()))
A = [[0 for _ in range(C)] for j in range(200001)]
for i in range(N):
    s,t,c = list(map(int,input().split()))
    for j in range(s*2-1,t*2):
        A[j][c-1] = 1
R = 0
for i in range(200001):
    sumA = sum(A[i])
    if R < sumA:
        R = sumA
print(R)


# Optimized solution
N,C = list(map(int,input().split()))
A = [[0 for _ in range(C)] for j in range(100001)]
for i in range(N):
    s,t,c = list(map(int,input().split()))
    for j in range(s-1,t):
        A[j][c-1] = 1
R = 0
for i in range(100001):
    sumA = sum(A[i])
    if R < sumA:
        R = sumA
print(R)
# Original solution
N,C = list(map(int,input().split()))
STC = [[] for _ in range(C)]
for i in range(N):
    s,t,c = list(map(int,input().split()))
    STC[c-1].append((s,t))

lenA = 200001
A = [[0]*lenA for _ in range(C)]
for i in range(N):
    a = 1

for i in range(C):
    for (s,t) in STC[i]:
        A[i][s*2-1] += 1
        A[i][t*2] -= 1

for i in range(C):
    for j in range(lenA-1):
        A[i][j+1] += A[i][j]

Ans = [0]*lenA
for i in range(C):
    for j in range(lenA):
        if A[i][j] > 0:
            Ans[j] += 1

print((max(Ans)))


# Optimized solution
N,C = list(map(int,input().split()))
STC = [[] for _ in range(C)]
for i in range(N):
    s,t,c = list(map(int,input().split()))
    STC[c-1].append((s,t))

lenA = 200001
A = [[0]*lenA for _ in range(C)]
for i in range(C):
    for (s,t) in STC[i]:
        A[i][s*2-1:t*2] = [1]*(t*2-s*2+1)

Ans = [0]*lenA
for i in range(C):
    for j in range(lenA):
        if A[i][j] > 0:
            Ans[j] += 1

print((max(Ans)))