import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int n, c;
  readf("%d %d\n", &n, &c);
  
  auto r = new int[][](n, 3);
  foreach (i; 0..n) {
    r[i] = readln.chomp.split.to!(int[]);
  }

  sort!((a,b) => a[2] == b[2] ? a[1] < b[1] : a[2] < b[2])(r);

  foreach (i; 1..n) {
    if (r[i-1][2] == r[i][2] && r[i-1][1] == r[i][0]) {
      r[i][0] = r[i-1][0];
      r[i-1][0..2] = 10^^5+1;
    }
  }

  auto d = new int[](10^^5+3);
  foreach (i; 0..n) {
    d[r[i][0]]++;
    d[r[i][1]+1]--;
  }
  int m, lm;
  foreach (i; 0..10^^5+1) {
    lm += d[i];
    m = max(m, lm);
  }
  m.writeln;
}
