#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, cn;
  cin >> n >> cn;
  vector<int> s(n), t(n), c(n);
  for (int(i) = (0); (i) < (n); (i)++) {
    cin >> s[i] >> t[i] >> c[i];
  }
  long t_max = pow(10, 5) * 2;
  vector<vector<int>> schedule(cn, vector<int>(t_max));
  for (int(i) = (0); (i) < (n); (i)++) {
    for (int(j) = (s[i] * 2 - 1); (j) < (t[i] * 2); (j)++) {
      schedule[c[i] - 1][j] = 1;
    }
  }
  int max = 0;
  for (int(i) = (0); (i) < (t_max); (i)++) {
    int count = 0;
    for (int(j) = (0); (j) < (cn); (j)++) {
      count += schedule[c[j] - 1][i];
    }
    if (count > max) max = count;
  }
  cout << max;
}
