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
41
42
43
44
45
46
47
48
49
50
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define N 100010
#define deb 0

using namespace std;

/*
    OwO! *notices you are looking at my code~* Have a nice day! INI_OK 100

    Przepraszam :(
*/

vector <int> zami[N];
int kol[4];

int main()
{
    if(!deb){
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }


    int n, p, k, t, m;
    cin >> n >> m;

    for(int i=0;i<m;i++)
    {
        cin >> p >> k >> t;
        zami[p].push_back(t);
        zami[k+1].push_back(-t);
    }

    int ile=0;
    for(int i=1;i<=n;i++)
    {
        for(auto e:zami[i])
        {
            kol[abs(e)]+=e/abs(e);
        }
        if(kol[1]>0 && kol[2]>0 && kol[3]==0) ile++;
    }

    cout << ile;
    return 0;
}