1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <vector>
using namespace std;

int n,m,l,r,k,s,x;



int main()
{
    cin>>n>>m;
vector<int>v[n+1];


    for(int i=1;i<=m;++i ){
        cin>>l>>r>>k;
        for(int j=l;j<=r;++j){
            v[j].push_back(k);
        }
    }
    for(int i=1;i<=n;++i){
        x=0;
        if(v[i].size()>1){
           for(int j=0;j<v[i].size();++j){
                if(v[i][j]==3){
                    x=0;
                    break;
                }
                x=1;
        }

        }

    if(x==1)
        s++;
}

cout<<s;
return 0;
}