#include <bits/stdc++.h>
using namespace std;

int main(){
  int a,b,c,N;
  cin>>N>>c;
  vector<int> X(100010,0);
  vector<pair<int,pair<int,int>>> Q;
  for(int i=0;i<N;i++){
    cin>>a>>b>>c;
    Q.push_back({c,{a,b}});
  }
  sort(Q.begin(),Q.end());
  
  for(int i=0;i<N;i++){
    a=Q[i].second.first;
    b=Q[i].second.second;
    c=Q[i].first;
    if(i<N-1&&Q[i+1].first==c){
      if(Q[i+1].second.first==b){
        X[b]--;X[b+1]++;
      }
    }
    X[a]++;X[b+1]--;
  }
  c=0;
  for(int i=1;i<100010;i++){
    X[i]+=X[i-1];
    c=max(c,X[i]);
  }
  cout<<c<<endl;
}