CodeEff/ECCO huggingface dataset:
# Original solution
# -*- coding: utf-8 -*-

N, C = list(map(int, input().split()))
T = 10**5+2

c_ls = [[0] * T for _ in range(C)]
# いもす
for i in range(N):
    s, t, c = list(map(int, input().split()))
    c_ls[c-1][s] += 1
    c_ls[c-1][t] -= 1
# 各チャンネル毎の累積和
for i in range(C):
    for j in range(1, T):
        c_ls[i][j] += c_ls[i][j-1]
# 他チャンネルとの重複を見るために開始を1早める
for i in range(C):
    for j in range(1, T):
        if c_ls[i][j] > c_ls[i][j-1]:
            c_ls[i][j-1] += 1
# 全チャンネルを合計
sm = [0] * T
for i in range(C):
    for j in range(T):
        sm[j] += c_ls[i][j]
# 重複が一番多くなる箇所が答え
print((max(sm)))


# Optimized solution
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = MAP()
C = [[] for i in range(M)]
for i in range(N):
    l, r, c = MAP()
    c -= 1
    C[c].append((l, r))

# 同チャンネルで連続する区間をまとめる
LR = []
for i in range(M):
    if C[i]:
        C[i].sort()
        LR.append(C[i][0])
        for j in range(1, len(C[i])):
            l1, r1 = C[i][j-1]
            l2, r2 = C[i][j]
            if r1 == l2:
                LR.pop()
                LR.append((l1, r2))
                # 3連続以上を考慮して更新
                C[i][j] = (l1, r2)
            else:
                LR.append((l2, r2))

# いもす法
MAX = 10 ** 5 + 7
imos = [0] * MAX
for l, r in LR:
    imos[l-1] += 1
    imos[r] -= 1
imos = list(accumulate(imos))
print((max(imos)))
# Original solution

if __name__ == "__main__":
    n,c  = list(map(int, input().split()))

    timeline = {}
    for i in range(n):
        s, t, c = list(map(int, input().split()))
        for i in range(s-1, t):
            xs = timeline.get(i, None)
            if xs is None:
                xs = set()
            xs.add(c)
            timeline[i] = xs
    print((max([len(v) for k, v in list(timeline.items())])))


# Optimized solution
def getter(starts, ends):
    while starts:
        if starts[-1][0] < ends[-1][1]:
            yield (starts.pop(), True)
        else:
            yield (ends.pop(), False)


def foo(C, targets):
    starts = sorted(targets, key=lambda x:x[0], reverse=True)
    ends = sorted(targets, key=lambda x: x[1], reverse=True)

    result = 0
    active = [0]*(C+1)
    for x, p in getter(starts, ends):
        if p:
            active[x[2]] += 1
        else:
            active[x[2]] -= 1
        result = max(result, sum([1 if x > 0 else 0 for x in active]))
    return result


if __name__ == "__main__":
    n, C  = list(map(int, input().split()))

    targets = []
    for i in range(n):
        s, t, c = list(map(int, input().split()))
        targets.append((s-1, t, c))
    print((foo(C, targets)))
# Original solution
N, C, *STC = list(map(int, open(0).read().split()))

T = [[0] * 10 ** 5 for _ in range(C + 1)]
for s, t, c in zip(*[iter(STC)] * 3):
    T[c][s - 1:t] = [1] * (t - s + 1)

print((max(list(map(sum, list(zip(*T)))))))

# Optimized solution
def main():
    N, C, *STC = list(map(int, open(0).read().split()))

    T = [[0] * 10 ** 5 for _ in range(C + 1)]
    for s, t, c in zip(*[iter(STC)] * 3):
        T[c][s - 1:t] = [1] * (t - s + 1)

    print((max(list(map(sum, list(zip(*T)))))))

main()
# Original solution
# -*- coding: utf-8 -*-
from operator import itemgetter

N,C = list(map(int, input().split()))
record = []
for _ in range(N):
    s,t,c = list(map(int, input().split()))
    record.append((s,t,c))
record.sort(key=itemgetter(1,0,2))

def can_record(k):
    slots = [(-1,-1)]*k  # (end_time, channel)

    for r in record:
        idx = -1
        t = -1
        for i in range(k):
            end_time, channel = slots[i]
            if channel==r[2]:
                if end_time<=r[0]:
                    if t<=end_time:
                        t = end_time
                        idx = i
            else:
                if end_time<r[0]:
                    if t<=end_time:
                        t = end_time
                        idx = i
        if idx==-1:
            return False
        else:
            slots[idx] = (r[1],r[2])
    return True

for k in range(1,C+1):
    if can_record(k):
        print(k)
        break


# Optimized solution
# -*- coding: utf-8 -*-
from operator import itemgetter

N,C = list(map(int, input().split()))
T = 0
record = []
for _ in range(N):
    s,t,c = list(map(int, input().split()))
    T = max(T, t)
    record.append((s,t,c))
record.sort(key=itemgetter(2,0,1))

tl = [0]*(T+1)
curr_channel = None
for r in record:
    s,t,c = r
    if curr_channel==c:
        if curr_time==s:
            tl[s] += 1
            tl[t] -= 1
        else:
            tl[s-1] += 1
            tl[t] -= 1
        curr_time = t
    else:
        tl[s-1] += 1
        tl[t] -= 1
        curr_channel = c
        curr_time = t

s = 0
res = 0
for t in tl:
    s += t
    res = max(res, s)
print(res)
# Original solution
import collections
N,C=list(map(int,input().split()))
#print N,C
d = collections.defaultdict(list)
start=float("inf")
end=0
for i in range(N):
	s,t,c=list(map(int,input().split()))
	d[c].append((s,t))
	start=min(start,s)
	end=max(end,t)

#print start,end
#print d
[d[i].sort() for i in list(d.keys())]
#print d

c = collections.defaultdict(list)

for i in range(start,end):
	#print "# i"
	#print i
	cnt=0
	for j in d:
		for k in d[j]:
			if i>=k[0] and i<=k[1]:
				#print j,"Yes"
				c[i].append(j)
				break;

#print c

max_recs=0
for i in list(c.values()):
	max_recs=max(max_recs,len(i))

print(max_recs)

	
	

# Optimized solution
import collections
N,C=list(map(int,input().split()))
a=collections.defaultdict(list)

max_t=0
for i in range(N):
	s,t,c=list(map(int,input().split()))
	a[c].append((s,t))
	max_t=max(max_t,t)

[a[i].sort() for i in list(a.keys())]
#print a
#print max_t

b=collections.defaultdict(list)


for i,j in list(a.items()):
	start=0
	end=0
	for k in j:
		if start==0 and end==0:
			start=k[0]-1
			end=k[1]
			continue
		elif k[0]<=end:
			end=k[1]
		else:
			b[i].append((start,end))
			start=k[0]-1
			end=k[1]
	else:
		b[i].append((start,end))		

#print "# b"
#print b

c=[0 for i in range(max_t+2)]

for i in list(b.values()):
	for j,k in i:
		#print j,1,k+1,-1
		c[j]+=1
		c[k]-=1
#print c

ans=0
sum=0
for i in c:
	sum+=i
	ans=max(ans,sum)

print(ans)
# Original solution
import collections
N,C=list(map(int,input().split()))
a=collections.defaultdict(list)

max_t=0
for i in range(N):
	s,t,c=list(map(int,input().split()))
	a[c].append((s,t))
	max_t=max(max_t,t)

[a[i].sort() for i in list(a.keys())]
#print a
#print max_t

b=collections.defaultdict(list)


for i,j in list(a.items()):
	start=0
	end=0
	for k in j:
		if start==0 and end==0:
			start=k[0]-1
			end=k[1]
			continue
		elif k[0]<=end:
			end=k[1]
		else:
			b[i].append((start,end))
			start=k[0]-1
			end=k[1]
	else:
		b[i].append((start,end))		

#print "# b"
#print b

c=[0 for i in range(max_t+2)]

for i in list(b.values()):
	for j,k in i:
		#print j,1,k+1,-1
		c[j]+=1
		c[k]-=1
#print c

ans=0
sum=0
for i in c:
	sum+=i
	ans=max(ans,sum)

print(ans)




# Optimized solution
# -*- coding: utf-8 -*-
import sys
from collections import deque

N,C=list(map(int, sys.stdin.readline().split())) 
stc=[ list(map(int, sys.stdin.readline().split())) for _ in range(N)]
stc.sort(key=lambda x:(x[0]) )
max_t=max(stc, key=(lambda x: x[1]))[1]

channel=[ deque() for _ in range(C+1) ]

for s,t,c in stc:
    try:
        prev_s,prev_t=channel[c].pop()
        if prev_t==s:
            channel[c].append((prev_s,t))
        else:
            channel[c].append((prev_s,prev_t))
            channel[c].append((s,t))
    except:
        channel[c].append((s,t))


T=[ 0 for _ in range(max_t+1) ] #時間軸

c=1
for c in range(1,C+1):  #チャンネル
    while channel[c]:
        s,t=channel[c].pop()
        for i in range(s,t+1):
            T[i]+=1

print(max(T))
# Original solution
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5) 
 
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from itertools import accumulate

N,C = li()
MAX = 10**5

stc = []
for _ in range(N):
    stc.append(list(li()))
    
rec = [[0 for _ in range(MAX+1)] for _ in range(C)]
for s,t,c in stc:
    rec[c-1][s-1] += 1
    rec[c-1][t] -= 1
    
for i in range(C):
    rec[i] = list(accumulate(rec[i]))
    rec[i] = [min(1,reci) for reci in rec[i]]
    
rec_total = rec[0]
    
for i in range(1,C):
    for j in range(MAX+1):
        rec_total[j] = rec_total[j] + rec[i][j]

print((max(rec_total)))

# Optimized solution
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from itertools import accumulate

n,ch = li()
MAX_T = 10**5+1

program = [[0]*MAX_T for _ in range(ch)]

endset = [set() for _ in range(ch)]
stc = []

for _ in range(n):
    s,t,c = li()
    c -= 1
    
    stc.append((s,t,c))
    endset[c].add(t)
    
stc.sort(key=lambda x:x[0])
    
for s,t,c in stc:
    if s in endset[c]:
        program[c][s] += 1
        program[c][t] -= 1
    else:
        program[c][s-1] += 1
        program[c][t] -= 1
    
for ci in range(ch):
    program[ci] = list(accumulate(program[ci]))
    
print((max([sum(time_span) for time_span in zip(*program)])))
# Original solution
N,C = list(map(int,input().split()))
ch = {}
for _ in range(N):
    s,t,c = list(map(int,input().split()))
    if c not in ch:
        ch[c] = [0 for _ in range(2*10**5+2)]
    for i in range(2*s-1,2*t):
        ch[c][i]=1
cmax = 0
for i in range(2*10**5+2):
    cnt = 0
    for c in ch:
        if ch[c][i]==1:
            cnt += 1
    cmax = max(cmax,cnt)
print(cmax)

# Optimized solution
N,C = list(map(int,input().split()))
G = {i:[0 for _ in range(10**5+1)] for i in range(1,C+1)}
for i in range(N):
    s,t,c = list(map(int,input().split()))
    G[c][s] += 1
    G[c][t] -= 1
F = [0 for _ in range(2*(10**5)+1)]
for c in range(1,C+1):
    for i in range(10**5+1):
        if G[c][i]==1:
            F[2*i-1] += 1
        elif G[c][i]==-1:
            F[2*i] -= 1
H = [0 for _ in range(2*(10**5)+1)]
for i in range(1,2*(10**5)+1):
    H[i] = H[i-1]+F[i]
print((max(H)))
# Original solution
N,C = list(map(int,input().split()))
STC = []
for _ in range(N):
  s,t,c = list(map(int,input().split()))
  STC.append([s,t,c])
STC.sort()

rs = [[STC[0][1],STC[0][2]]]
for i in range(1,N):
  len_rs = len(rs)
  
  min_idx = None
  for j in range(len_rs):
    if rs[j][1] != STC[i][2]: tmp_stc_r = STC[i][0] - 0.5
    else: tmp_stc_r = STC[i][0]
 
    if rs[j][0] <= tmp_stc_r:
      if min_idx is None: min_idx = j
      else:
        if rs[j][0] < rs[min_idx][0]: min_idx = j

  if min_idx is None: rs.append([STC[i][1], STC[i][2]])
  else: rs[min_idx] = [STC[i][1], STC[i][2]]
  
  rs.sort()
print((len(rs)))

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

rs = [[STC[0][1],STC[0][2]]]
for i in range(1,N):
  len_rs = len(rs)
  
  min_idx = None
  for j in range(len_rs):
    if rs[j][1] != STC[i][2]: tmp_stc_r = STC[i][0] - 0.5
    else: tmp_stc_r = STC[i][0]
 
    if rs[j][0] <= tmp_stc_r:
      if min_idx is None: min_idx = j
      else:
        if rs[j][0] < rs[min_idx][0]: min_idx = j

  if min_idx is None: rs.append([STC[i][1], STC[i][2]])
  else: rs[min_idx] = [STC[i][1], STC[i][2]]
  
print((len(rs)))
# Original solution
N,C = list(map(int,input().split()))
STC = []
for _ in range(N):
  s,t,c = list(map(int,input().split()))
  STC.append([s,t,c])
STC.sort()

rs = [[STC[0][1],STC[0][2]]]
for i in range(1,N):
  len_rs = len(rs)
  
  min_idx = None
  for j in range(len_rs):
    if rs[j][1] != STC[i][2]: tmp_stc_r = STC[i][0] - 0.5
    else: tmp_stc_r = STC[i][0]
 
    if rs[j][0] <= tmp_stc_r:
      if min_idx is None: min_idx = j
      else:
        if rs[j][0] < rs[min_idx][0]: min_idx = j

  if min_idx is None: rs.append([STC[i][1], STC[i][2]])
  else: rs[min_idx] = [STC[i][1], STC[i][2]]
  
print((len(rs)))

# Optimized solution
import sys

N,C = list(map(int,input().split()))
STC = []
for _ in range(N):
  s,t,c = list(map(int,sys.stdin.readline().split()))
  STC.append([s,t,c])
STC.sort()

rs = [[STC[0][1],STC[0][2]]]
for i in range(1,N):
  len_rs = len(rs)
  
  min_idx = None
  for j in range(len_rs):
    if rs[j][1] != STC[i][2]: tmp_stc_r = STC[i][0] - 0.5
    else: tmp_stc_r = STC[i][0]
 
    if rs[j][0] <= tmp_stc_r:
      if min_idx is None: min_idx = j
      else:
        if rs[j][0] < rs[min_idx][0]: min_idx = j

  if min_idx is None: rs.append([STC[i][1], STC[i][2]])
  else: rs[min_idx] = [STC[i][1], STC[i][2]]
  
print((len(rs)))
# Original solution
n,C = list(map(int,input().split()))
INF = float("INF")
ch = [[0]*(200001) for _ in range(C)]
m = 0
for _ in range(n):
    s,t,c = list(map(int,input().split()))
    s = s*2-1
    t *= 2
    c -= 1
    ch[c][s] += 1
    ch[c][t] -= 1
    m = max(m,t)

cnt = [0]*(m+1)
for c in range(C):
    for i in range(1,m+1):
        ch[c][i] += ch[c][i-1]
        if ch[c][i-1] == 0 and ch[c][i] > 0: cnt[i] += 1
        if ch[c][i-1] > 0 and ch[c][i] == 0: cnt[i] -= 1

for i in range(1,m+1): cnt[i] += cnt[i-1]
print((max(cnt)))

# Optimized solution
n,C = list(map(int,input().split()))
ch = [[0]*(200001) for _ in range(C)]
m = 0
for _ in range(n):
    s,t,c = list(map(int,input().split()))
    s = s*2-1
    t *= 2
    c -= 1
    ch[c][s] += 1
    ch[c][t] -= 1
    m = max(m,t)

cnt = [0]*(m+1)
for c in range(C):
    for i in range(1,m+1):
        ch[c][i] += ch[c][i-1]
        if ch[c][i-1] == 0 and ch[c][i] > 0: cnt[i] += 1
        if ch[c][i-1] > 0 and ch[c][i] == 0: cnt[i] -= 1

for i in range(1,m+1): cnt[i] += cnt[i-1]
print((max(cnt)))
# Original solution
def func():
    tvs = []
    for i in range(num):
        tvs.append((-1, -1))
    for i in range(len(bans)):
        now = bans[i][0]
        can = bans[i][2]
        tvs = [tv for tv in tvs if tv[1] == can] + [tv for tv in tvs if tv[1] != can]
        for j, tv in enumerate(tvs):
            if tv[1] == -1 or (tv[1] == can and tv[0] <= now) or tv[0] <= now - 1:
                del tvs[j]
                tvs.append((bans[i][1], can))
                break
        else:
            return False
    return True


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

bans = []
for i in range(n):
    bans.append(tuple(map(int, input().split())))
bans.sort(key=lambda x: x[0])

for num in range(1, 1024):
    if func():
        print(num)
        break


# Optimized solution
def func():
    tvs = []
    for i in range(num):
        tvs.append((-1, -1))
    for i in range(len(bans)):
        now = bans[i][0]
        can = bans[i][2]
        # tvs = [tv for tv in tvs if tv[1] == can] + [tv for tv in tvs if tv[1] != can]
        for j, tv in enumerate(tvs):
            if tv[1] == -1 or (tv[1] == can and tv[0] <= now) or tv[0] <= now - 1:
                del tvs[j]
                tvs.append((bans[i][1], can))
                break
        else:
            return False
    return True


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

bans = []
for i in range(n):
    bans.append(tuple(map(int, input().split())))
bans.sort(key=lambda x: x[0])

for num in range(1, 1024):
    if func():
        print(num)
        break
# Original solution
N, C = list(map(int, input().split()))
program = []
program_list = [0 for _ in range((((10 ** 5) * 2) + 10))]
for _ in range(C + 1):
    program.append(program_list.copy())
sm = program_list.copy()

s_list = []
t_list = []
c_list = []
for _ in range(N):
    s, t, c = list(map(int, input().split()))
    s_list.append(s)
    t_list.append(t)
    c_list.append(c)

for i in range(1, C + 1):
    for j in range(len(s_list)):
        if i == c_list[j]:
            program[i][(s_list[j] * 2) - 1] += 1
            program[i][(t_list[j] * 2)] -= 1
    for j in range(1, len(program_list)):
        program[i][j] += program[i][j - 1]
    for j in range(0, len(program_list)):
        if program[i][j] > 0:
            sm[j] += 1
print((max(sm)))


# Optimized solution
N, C = list(map(int, input().split()))
program = []
program_list = [False for _ in range((((10 ** 5) * 2) + 10))]
for _ in range(C + 1):
    program.append(program_list.copy())

for _ in range(N):
    s, t, c = list(map(int, input().split()))
    s2 = (t * 2) - ((s * 2) - 1)
    program[c][(s * 2) - 1:t * 2] = [True] * s2

max_c = 0
for i in range(len(program_list)):
    c = 0
    for j in range(1, C + 1):
        if program[j][i]:
            c += 1
        if c > max_c:
            max_c = c
print(max_c)
# Original solution
N,C = list(map(int,input().split()))
T = [[0 for i in range(10**5+1)] for j in range(30)]

for i in range(N):
    s,t,c = list(map(int,input().split()))
    T[c-1][s] += 1
    T[c-1][t] -= 1
for i in range(C):
    for j in range(10**5):
        T[i][j+1] += T[i][j]

for i in range(C):
    for j in range(10**5):
        if T[i][-j-1] == 0 and T[i][-j-2] == 1:
            T[i][-j-1] = 1
ans = 0
for i in range(10**5+1):
    ans = max(ans,sum(T[j][i] for j in range(C)))
print(ans)

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

t = [[0 for i in range(100001)] for j in range(c)]

for i in range(n):
    si,ti,ci = list(map(int,input().split()))
    for j in range(si,ti+1):
        t[ci-1][j] = 1
ans = 0
for i in range(100001):
    ans = max(ans,sum(t[j][i] for j in range(c)))
print(ans)
# Original solution
N,C = list(map(int,input().split()))
src = [list(map(int,input().split())) for i in range(N)]
MAX = 10**5
bucket = [[] for i in range(MAX+2)]
bucket2 = [set() for i in range(MAX+2)]
for s,t,c in src:
    bucket[s].append((t,c))
    bucket2[s].add(c)

imos = [0]*(MAX+2)

for s in range(MAX):
    for t,c in bucket[s]:
        imos[s-1] += 1
        if c in bucket2[t]:
            imos[t-1] -= 1
        else:
            imos[t] -= 1

ans = tmp = 0
for im in imos:
    tmp += im
    ans = max(ans, tmp)
print(ans)

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

cs = [[] for _ in range(30)]
for s,t,c in STC:
    cs[c-1].append((s,t))

imos = [0]*(100005)
for c in cs:
    c.sort(key=lambda x:x[0])
    pt = -1
    for s,t in c:
        if s==pt:
            imos[s] += 1
        else:
            imos[s-1] += 1
        imos[t] -= 1
        pt = t
for i in range(len(imos)-1):
    imos[i+1] += imos[i]
print((max(imos)))
# Original solution
N,C = list(map(int,input().split()))

P = [[] for i in range(C)]

for i in range(N):
    s,t,c = list(map(int,input().split()))
    P[c-1].append([s,"S"])
    P[c-1].append([t,"T"])

P = [sorted(sorted(P[i],key=lambda x:x[1]),key=lambda x: x[0]) for i in range(C)]
#print(P)
P2 = []

for i in range(C):
    for j in range(len(P[i])):
        if P[i][j][1]=="T":
            if j!=0:
                if P[i][j][0]!=P[i][j-1][0]:
                    P2.append(P[i][j])
            else:
                P2.append(P[i][j])
        else:
            if j!=len(P[i])-1:
                if P[i][j][0]!=P[i][j+1][0]:
                    P2.append([P[i][j][0]-0.5,P[i][j][1]])
            else:
                P2.append([P[i][j][0]-0.5,P[i][j][1]])

P = P2
P = sorted(P,key=lambda x:x[0])

count=0
max_count=0
s_buf = 0
t_buf = 0

prev = -1
for i in range(len(P)):
    if prev!=P[i][0]:
        prev=P[i][0]
        count+=s_buf-t_buf
        s_buf=0
        t_buf=0
        max_count=max(count,max_count)
    if P[i][1]=="S":
        s_buf+=1
    else:
        t_buf+=1
#print(P)
count+=s_buf-t_buf
max_count=max(count,max_count)

print(max_count)

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

program_list = []

for i in range(N):
    s,t,c = list(map(int,input().split()))
    program_list.append((s-0.5,"s",c-1))
    program_list.append((t,"t",c-1))

program_list.sort(key=lambda x:x[0])

c_list=[0 for i in range(C)]
count_list=[0 for i in range(C)]

max_num=0
for i in range(2*N):
    if program_list[i][1]=="s":
        c = program_list[i][2]
        count_list[c]+=1
        c_list[c] = min(1,count_list[c])
        max_num=max(sum(c_list),max_num)
    else:
        c = program_list[i][2]
        count_list[c]-=1
        c_list[c] = min(1,count_list[c])

print(max_num)
# Original solution
def LI(): return list(map(int, input().split()))
def LS(): return input().split()
def I(): return int(eval(input()))
def S(): return eval(input())

n, c = LI()
l = []
for i in range(n):
    l.append(LI())

start = 0
end = 0
ans = 0
l.sort(key=lambda x: x[1])
#print(l)
while(len(l) > 0):
    ans += 1
    start = l[0][0]
    end = l[0][1]
    l = l[1:]
    if len(l) < 1:
        break
    remove_ind = []
    for ind, i in enumerate(l):
        if i[0] > end:
            start = i[0]
            end = i[1]
            remove_ind .append(ind)
    l = [l[i] for i in range(len(l)) if i not in remove_ind]
print(ans)


# Optimized solution
def LI(): return list(map(int, input().split()))
def LS(): return input().split()
def I(): return int(eval(input()))
def S(): return eval(input())

n, c = LI()
l = []
for i in range(n):
    l.append(LI())

#チャンネル見る必要がある
#同じチャンネルで連続しているものはくっつける
la = [[[], []] for i in range(c)]
for i in l:
    la[i[2] - 1][0].append(i[0])
    la[i[2] - 1][1].append(i[1])

starts = []
ends = []
for s, e in la:
    wa = set(s).union(set(e))
    seki = set(s).intersection(set(e))
    a = list(wa.difference(seki))
    a.sort()
    for i, j in zip(a[0::2], a[1::2]):
        starts.append(i)
        ends.append(j)

s = min(starts)
e = max(ends)

imos = [0 for i in range(s,e + 2)]
for i, j in zip(starts, ends):
    imos[i - s] += 1
    imos[j - s + 1] -= 1
for i in range(len(imos) - 1):
    imos[i + 1] += imos[i]

print((max(imos)))
# Original solution
n,c = list(map(int,input().split()))

arr = [[0 for i in range((10**5+2) * 2)] for i in range(c)]

for i in range(n):
	s,t,ch = list(map(int,input().split()))
	arr[ch-1][s*2-1] = 1
	arr[ch-1][t*2] = -1

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



ans = 0
for i in range(((10**5+2)*2)):
	count = 0
	for j in range(c):
		if arr[j][i] > 0 :
			count += 1

	ans = max(ans,count)

print(ans)



# Optimized 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 

ans = 0
for i in range(100000):
    if sum(r[i]) > ans:
        ans = sum(r[i]) 

print(ans)
# Original solution
n,c=[int(i) for i in input().split()]
s=[]
t=[]
for _ in range(n):
  a=[int(i) for i in input().split()]
  s.append(a[0]-0.5)
  t.append(a[1])

s.sort()
t.sort()
x=0
m=0
while s !=[] or t !=[]:
  if s==[]:
    x-=1
    del t[0]
  elif t==[]:
    x+=1
    del s[0]
  else:
    if s[0] < t[0]:
      x+=1
      del s[0]
    else:
      x-=1
      del t[0]
  m=max(m,x)
print(m)

# Optimized solution
n,c=[int(i) for i in input().split()]
s0=[]
t0=[]
for _ in range(n):
  a=[int(i) for i in input().split()]
  s0.append((a[0],a[2]))
  t0.append((a[1],a[2]))
s1=set(s0)
t1=set(t0)
s2=list(s1.difference(t0))
t2=list(t1.difference(s0))
s=[i[0]-0.5 for i in s2]
t=[i[0] for i in t2]

s.sort()
t.sort()
x=0
m=0
si=0
ti=0
while si != len(s):
  if s[si] < t[ti]:
    x+=1
    si+=1
  else:
    x-=1
    ti+=1
  m = max(m,x)
print(m)