#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define C_MAX 30
#define N_MAX 100000

int main(){
  int n, c;
  cin >> n >> c;

  bool r[N_MAX][C_MAX];

  REP(i, N_MAX){
    REP(j, C_MAX){
      r[i][j] = 0;
    }
  }

  int min_x = N_MAX;
  int max_y = 0;
  REP(i, n){
    int x, y, z;
    cin >> x >> y >> z;
    FOR(j, x - 1, y - 1){
      r[j][z - 1] = 1;
    }
    min_x = min(min_x, x - 1);
    max_y = max(max_y, y - 1);
  }

  int ans = 1;
  FOR(i, min_x, max_y){
    ans = max(ans, std::accumulate(r[i], r[i] + C_MAX, 0));
  }

  cout << ans << endl;

  return 0;
}
