#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
template<class T1> void sortA_L(int N, T1 a[], void *mem = wmem){
  sort(a, a+N);
}
template<class T1, class T2> void sortA_L(int N, T1 a[], T2 b[], void *mem = wmem){
  int i;
  pair<T1, T2> *arr;
  walloc1d(&arr, N, &mem);
  for(i=(0);i<(N);i++){
    arr[i].first = a[i];
    arr[i].second = b[i];
  }
  sort(arr, arr+N);
  for(i=(0);i<(N);i++){
    a[i] = arr[i].first;
    b[i] = arr[i].second;
  }
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> void wAdjEdge_L(const int N, const int M, const int *A, const S *B, const T *C, int **res_sz, S ***res_B, T ***res_C, void **mem = &wmem){
  int i;
  int j;
  int k;
  walloc1d(res_sz, N, mem);
  for(i=(0);i<(N);i++){
    (*res_sz)[i] = 0;
  }
  for(i=(0);i<(M);i++){
    (*res_sz)[A[i]]++;
  }
  walloc1d(res_B, N, mem);
  for(i=(0);i<(N);i++){
    walloc1d(&((*res_B)[i]), (*res_sz)[i], mem);
  }
  walloc1d(res_C, N, mem);
  for(i=(0);i<(N);i++){
    walloc1d(&((*res_C)[i]), (*res_sz)[i], mem);
  }
  for(i=(0);i<(N);i++){
    (*res_sz)[i] = 0;
  }
  for(i=(0);i<(M);i++){
    (*res_B)[A[i]][(*res_sz)[A[i]]] = B[i];
    (*res_C)[A[i]][(*res_sz)[A[i]]] = C[i];
    (*res_sz)[A[i]]++;
  }
}
int N;
int M;
int S[100000];
int T[100000];
int C[100000];
int *sz;
int **s;
int **t;
int arr[100001];
int main(){
  int i, k;
  wmem = memarr;
  rd(N);
  rd(M);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(S[Lj4PdHRW]);S[Lj4PdHRW] += (-1);
      rd(T[Lj4PdHRW]);T[Lj4PdHRW] += (-1);
      rd(C[Lj4PdHRW]);C[Lj4PdHRW] += (-1);
    }
  }
  wAdjEdge_L(M,N,C,S,T,&sz,&s,&t);
  for(k=(0);k<(M);k++){
    int i;
    sortA_L(sz[k], s[k], t[k]);
    for(i=(0);i<(sz[k]);i++){
      arr[s[k][i]]++;
      while(i+1 < sz[k] && t[k][i] == s[k][i+1]){
        i++;
      }
      arr[t[k][i]+1]--;
    }
  }
  for(i=(1);i<(100001);i++){
    arr[i] += arr[i-1];
  }
  {
    int KL2GvlyY;
    int Q5VJL1cS;
    if(100001==0){
      Q5VJL1cS = 0;
    }
    else{
      Q5VJL1cS = arr[0];
      for(KL2GvlyY=(1);KL2GvlyY<(100001);KL2GvlyY++){
        Q5VJL1cS = max_L(Q5VJL1cS, arr[KL2GvlyY]);
      }
    }
    wt_L(Q5VJL1cS);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190925-1

// --- original code ---
// int N, M;
// int S[1d5], T[1d5], C[1d5];
// 
// int *sz, **s, **t;
// int arr[100001];
// 
// {
//   rd(N,M,(S--,T--,C--)(N));
//   wAdjEdge(M,N,C,S,T,&sz,&s,&t);
//   rep(k,M){
//     sortA(sz[k], s[k], t[k]);
//     rep(i,sz[k]){
//       arr[s[k][i]]++;
//       while(i+1 < sz[k] && t[k][i] == s[k][i+1]) i++;
//       arr[t[k][i]+1]--;
//     }
//   }
//   rep(i,1,100001) arr[i] += arr[i-1];
//   wt(max(arr(100001)));
// }


Measured memory_bytes: 4352