#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
int n, m;
vector<int> v;
vector<pair<pair<int, int>, int> > vc;
map<int, int> mp;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  if (n == 0 && m == 0) {
    cout << "0";
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    v.push_back(a);
  }
  sort(v.begin(), v.end());
  for (int i = 1; i <= m; i++) {
    int x1, x2, h;
    cin >> x1 >> x2 >> h;
    vc.push_back(make_pair(make_pair(x1, x2), h));
  }
  sort(vc.begin(), vc.end());
  multiset<int> hs;
  int ind = 0;
  int ans = 1e9;
  for (int i = 0; i <= n; i++) {
    int hh;
    if (i == n)
      hh = 1000000000;
    else
      hh = v[i];
    while (ind < vc.size() && vc[ind].first.first <= hh) {
      int h = vc[ind].second;
      int l = mp[h];
      l = l + vc[ind].first.second - vc[ind].first.first + 1;
      if (l == vc[ind].first.second) {
        hs.insert(l);
        mp[h] = l;
      }
      ind++;
    }
    multiset<int>::iterator it = hs.lower_bound(hh);
    hs.erase(hs.begin(), it);
    int t = hs.size();
    ans = min(ans, t + i);
  }
  cout << ans;
  return 0;
}
