#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,c=map(int,input().split())\n"
"r=[[0,0]for _ in range(c)]\n"
"for s,t,c in sorted(list(map(int,input().split()))for _ in range(n)):\n"
"    for m in r:\n"
"        if m[0]<s-0.5or m[1]==c and m[0]<=s:\n"
"            m[0],m[1]=t,c\n"
"            break\n"
"print(len(list(filter(lambda x:x!=[0,0],r))))\n"
"\"";
  system(s);
  return 0;
}            