1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <stdlib.h>
#include <vector>
using namespace std;

int main()
{
	int puszki, n, sum = 0, a, b, k;
	cin >> puszki >> n;
	vector<vector<int>> vec(puszki, vector<int>(3, 0));
	for (int i = 0; i < n; i++){
		cin >> a >> b >> k;
		for (int j = a; j <= b; j++) {
			if (vec[j][k - 1] == 0)
				vec[j][k - 1] = 1;
		}
	}
	for (int i = 0; i < puszki; i++) {
		if (vec[i][0] == 1 && vec[i][1] == 1 && vec[i][2] == 0)
			sum++;
	}
	cout << sum;
	return(0);
}