#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
int imos[30][200001];
int main() {
	int N, C;
	cin >> N >> C;
	for (int i = 0; i < N; i++) {
		int s, t, c;
		cin >> s >> t >> c;
		c--;
		s = s * 2 - 1;
		t *= 2;
		imos[c][s]++;
		imos[c][t]--;
	}
	for (int i = 0; i < C; i++) {
		for (int j = 1; j <= 200000; j++) {
			imos[i][j] += imos[i][j - 1];
		}
	}
	int ans = 0;
	for (int i = 0; i <= 200000; i++) {
		int sum = 0;
		for (int j = 0; j < C; j++) {
			if (imos[j][i] >= 1) sum++;
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
}