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
#include <iostream>
using namespace std;

bool tab[1000001][4];

int main() {
	ios_base::sync_with_stdio(0);
	int n, o, l, r, k;
	cin >> n >> o;
	for(int i=0;i<o;i++){
		cin >> l >> r >> k;
		for (int j=l;j<=r;j++) {
			tab[j][k] = true;
		}
	}
	
	int sum = 0;
	for (int i=1;i<=n;i++) {
		if (tab[i][1] == true && tab[i][2] == true && tab[i][3] == false)
			sum++;
	}
	
	cout << sum;
	return 0;
}