1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    unsigned int n, m; cin >> n >> m;
    vector<int> puszki(n, 1);
    int f[3] = { 2, 3, 5 }; // factors
    for (int i = 0; i < m; i++) {
        int l, r, k; cin >> l >> r >> k;
        for (int j = l; j <= r; j++) puszki[j] *= f[k-1];
    }

    int c = 0;
    for (int i = 0; i < n; i++) {
        if (!(puszki[i] % 2) && !(puszki[i] % 3) && puszki[i] % 5) c++;
    }
    cout << c << endl;
    return 0;
}