#include <bits/stdc++.h>
using namespace std;
int n, c;
int tm[200001];
int main() {
  cin >> n >> c;
  for (int i = 0; i < 200001; i++) tm[i] = 0;
  for (int i = 0; i < n; i++) {
    int s, t, c;
    cin >> s >> t >> c;
    tm[2 * s - 1]++;
    tm[2 * t]--;
  }
  int ans = 0;
  for (int i = 1; i < 200001; i++) {
    tm[i] += tm[i - 1];
    ans = max(ans, tm[i]);
  }
  cout << ans << endl;
  return 0;
}
