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

void check(int n, int m){
	int i = 0;
	int x,y,c;
	bool check;
	char b;
	bool a[n][3] = {0};
	while(m-- > 0){
		cin >> x >> y >> c;
		for(i = x-1; i < y; i++){
			a[i][c-1] = true;
		}
	}
	int counter = 0;
	for(int i = 0; i < n; i++){
		if(a[i][0] == true && a[i][1] == true && a[i][2] == false)
			counter++;
	}
	cout << counter;
}
int main(){
	int n, m;
	cin >> n >> m;
	check(n,m);
	return 0;	
}