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
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);


    long n,m,r,l,k;
    cin >> n >> m;
    int *puszki = new int[n+1];
    for(long i = 0; i<=n; i++)
        puszki[i] = 0;

    while(m--){
        cin >> l >> r >> k;
        for(long i = l; i<=r; i++){
            puszki[i]|=(1<<k);
        }
    }

    long suma=0;
    for(int i = 1; i<n+1; i++){
        if(puszki[i]==6)
            suma++;
    }

    cout << suma;

    return 0;
}