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
#include <bits/stdc++.h>
#include <vector>
using namespace std;

// enum color {
//     white = 0,
//     yellow = 1,
//     blue = 2,
//     green = 3,
//     red = 4,
//     orange = 5,
//     violet= 6,
//     brown = 7
// };
int solve() {
  int total;
  cin >> total;
  int op_count;
  cin >> op_count;
  vector<int> cans(total+1, 0);
  for(int i=0; i < op_count; ++i) {
    int from;
    cin >> from;
    int to;
    cin >> to;
    int val;
    cin >> val;
    for (int j=from; j<=to; ++j) {
        cans[j] |= (1 << (val - 1));
    }
  }
  int ans = 0;
  for (int e: cans) {
      ans += (e == 3);
  }
  cout << ans << endl;
  return 0;
}

int main() {
  solve();
}