#include <bits/stdc++.h>
using namespace std;
 
namespace
{
const int MAX_N	= 100000;
bool bC[ 31 ][ MAX_N + 5 ];
}
 
int main( int argc, char *argv[] )
{
int i;
int j;
int N;
int C;
int s;
int t;
int c;
int iMax;
int iCnt;
 
	ios::sync_with_stdio( false );
	cin.tie( 0 );
 
	cin >> N;
	cin >> C;
	for( i = 1; i <= N; i++ )
	{
		cin >> s;
		cin >> t;
		cin >> c;
		for( j = s - 1; j < t; j++ )
			bC[ c ][ j ] = true;
	}
 
	iMax = 0;
	for( j = 1; j <= MAX_N; j++ )
	{
		iCnt = 0;
		for( i = 1; i <= C; i++ )
		{
			if( bC[ i ][ j ] ) iCnt++;
		}
 
		if( iMax < iCnt ) iMax = iCnt;
	}
 
	cout << iMax << endl;
 
	return 0;
}