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

using namespace std;

int main(){
	
	unsigned int n;
	cin>>n; 
	
	unsigned int m;
	cin>>m;
	
	vector < vector<int> > tab;
	
	for(int i=0;i<n;i++){
		vector <int> v1;
		
		v1.push_back(0);
		v1.push_back(0);
		v1.push_back(0);
		
		tab.push_back(v1);
	}
	
	for(int i=0;i<m;i++){
		
		int l;
		cin>>l;
		
		int r;
		cin>>r;
		
		int k;
		cin>>k;
		
		for(int j=l-1;j<r;j++){
			tab[j][k-1]++;
		}
	}
	
	int suma = 0;
	
	for(int i=0;i<n;i++){
		if((tab[i][2]==0)&&(tab[i][0]>0)&&(tab[i][1]>0)) suma++;
	}
	
	cout<<suma;

	return 0;	
}