#include<cstdio>

const int MAX_N = 1e5;
int n, m;
bool judge[30][MAX_N];

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++) {
        int s, t, c;
        scanf("%d %d %d", &s, &t, &c);
        for (int j = s - 1; j < t; j++) judge[c - 1][j] = true;
    }
    
    int ans = 0;
    for (int i = 0; i < 100000; i++) {
        int cnt = 0;
        for (int j = 0; j < m; j++) {
            if (judge[j][i]) cnt++;
        }
        ans = (ans < cnt) ? cnt : ans;
    }
    
    printf("%d\n", ans);
    return 0;
} 
