#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>

using namespace std;

int Time[111111*2];
int RecTime[30][111111*2];

int main(){
  int n,c;
  cin>>n>>c;
  for(int i = 0;i<n;i++){
    int s,t,ch;
    cin>>s>>t>>ch;
    
    RecTime[ch-1][s*2-1]++;
    RecTime[ch-1][t*2]--;
    
    //isRec[ch-1][s*2-1] = true;
  }
  int ans = 0;
  for(int j = 0;j<30;j++){

    for(int i = 1;i<111111*2;i++){
      RecTime[j][i] += RecTime[j][i-1];
      if(RecTime[j][i] > 0)Time[i]++;
    }
  }
  for(int i = 1;i<111111*2;i++){
    ans = max(ans,Time[i]);
  }
    
  
  cout<<ans<<endl;

  return 0;
}
