#include <iostream>
#include <cstdio>
#define C 35
#define N 100005
using namespace std;

int n, c, cnt, mx;
bool v[C][N];
int main()
{
	int i, j, t1, t2, t3;
	cin >> n >> c;
	while (n--) {
		scanf("%d %d %d", &t1, &t2, &t3);
		for (i = t1; i <= t2; i++) v[t3][i] = 1;
	}
	for (i = 1; i < N; i++) {
		for (j = 1, cnt = 0; j <= c; j++) cnt += v[j][i];
		mx = max(mx, cnt);
	}
    cout << mx << endl;
    return 0;
}