#include <iostream>
#include <vector>
#include <algorithm>
#include <random>

using namespace std;
using ll = long long;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, q;
    cin >> n >> q;

    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    int ti, tl, tr;
    for (int _ = 0; _ < q; ++_) {
        cin >> ti >> tl >> tr;
        ti--;
        tl--;

        if (a[ti] == 1)
            for (int j = tl; j < tr; ++j)
                a[j] = 1;
    }

    int res = 0;
    for (auto el : a)
        res += el;

    cout << res;
}