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
#include <bits/stdc++.h>

using namespace std;

map<int, int> paints;

int main() {
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);

	int n, m, i, j, l, r, k, answer = 0;
	scanf("%d %d", &n, &m);

	for (i = 0; i < m; ++i) {
		scanf("%d %d %d", &l, &r, &k);

		for (j = l; j <= r; ++j) {
			paints[j] += k;
			if (paints[j] == 3)
				answer++;
		}
	}

	printf("%d\n", answer);

	return 0;
}