import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;

void main() {
  auto l = readln.chomp.split.map!(to!int).array;
  int n = l[0], c = l[1];
  long[][] cc = new long[][](31, 200010);
  long[] imos = new long[](200010);
  

  for (int i = 0; i < n; ++i) {
    auto m = readln.chomp.split.map!(to!int).array;
    cc[m[2] - 1][2 * m[0] - 1] += 1;
    cc[m[2] - 1][2 * m[1]] -= 1;
  }

  for (int i = 0; i < c; ++i) {
    for (int j = 1; j <= 200000; ++j) {
      cc[i][j] += cc[i][j - 1];
      if (cc[i][j - 1] == 0 && cc[i][j] > 0) {
        imos[j] += 1;
      }
      else if (cc[i][j] == 0 && cc[i][j - 1] > 0) {
        imos[j] -= 1;
      }
    }
  }

  long ans;

  for (int i = 1; i <= 200000; ++i) {
    imos[i] += imos[i - 1];
    if (ans < imos[i]) ans = imos[i];
  }

  ans.writeln;
}