#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

const int Max_n = 100003;
int cs[33][Max_n];
int active[33];

// 1901 - 19:18
int main(){
    int N, C, s, t ,c, ans=0;
    cin >> N >> C;

    for(int i =1; i <= N; i++){
        cin >> s >> t >> c;
        for(int j=s; j <=t; j++){
            cs[c][j] =1;
        }
    }

    for(int i =1; i < Max_n; i++){
        int temp=0;
        for(int j=1; j <=C; j++){
            if(cs[j][i] ==1) temp++;
        }
        ans = max(ans, temp);
    }


    cout << ans << endl;
  
   

    return 0;
}