import sequtils,algorithm proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "" .} proc scan(): int = while true: let k = getchar_unlocked() if k < '0' or k > '9': break result = 10 * result + k.ord - '0'.ord proc parseLine(): tuple[x,y:int] = let (x1,x2,x3) = (scan(),scan(),scan()) let (y1,y2,y3) = (scan(),scan(),scan()) result.x = x3 + x2 * 60 + x1 * 1440 result.y = y3 + y2 * 60 + y1 * 1440 let n = scan() let m = scan() let U = newSeqWith(m,parseLine()).sortedByIt(it.y) var preY = newSeq[int](n) var ans = 0 for u in U: preY.sort(cmp,Descending) for i in 0..= u.x: continue preY[i] = u.y ans += 1 break echo ans