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

int main() {
    int n; cin >> n;
    int m; cin >> m;
    
    vector <int> row(n,1);
    
    for (int M=0; M < m; M++) {
        int l; int r; int k;
        cin >> l >> r >> k;
        int x = 0;
        switch (k) {
            case 1: x = 2; break;
            case 2: x = 3; break;
            case 3: x = 5; break;
        }
        for (int i = l-1; i < r; i++) if (row[i] % x != 0) row[i] *= x;
    }
    int wynik = 0;
    for (int i=0; i < row.size(); i++) if (row[i] == 6) wynik++;
    cout << wynik << endl;
    
    return 0;
}