#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void) {
  int n, c, maxt = 200001;
  cin >> n >> c;
  vector<vector<int> > memo(c, vector<int>(maxt, 0));
  for (int i = 0; i < n; i++) {
    int s, t, cn;
    cin >> s >> t >> cn;
    for (int j = s * 2 - 1; j <= t * 2; j++) {
      memo[cn - 1][j] = 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < maxt; i++) {
    int sum = 0;
    for (int j = 0; j < c; j++) {
      sum += memo[j][i];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}