#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 229;
const long long M = 1e9 + 7;
const long long M2 = 1e9 + 9;
const long long mod = 998244353;
const int rx[4] = {1, -1, -1, 1};
const int ry[4] = {1, -1, 1, -1};
const double eps = 0.000001;
const double pi = acos(-1.0);
set<int> x;
multiset<int> y;
unordered_map<int, set<pair<int, int> > > seg;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  srand(time(0));
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    int z;
    cin >> z;
    x.insert(z);
  }
  for (int i = 0; i < m; ++i) {
    int x1, x2, y;
    cin >> x1 >> x2 >> y;
    seg[y].insert({x1, x2});
  }
  for (auto now : seg) {
    int last = 0;
    for (auto i : now.second) {
      if (i.first > last + 1) {
        break;
      }
      last = i.second;
    }
    y.insert(last);
  }
  x.insert(1e9);
  int now = int(y.size());
  int ot = now;
  for (auto i : x) {
    while (!y.empty() && *y.begin() < i) {
      y.erase(y.find(*y.begin()));
      --now;
    }
    ot = min(ot, now);
    ++now;
  }
  cout << ot;
  return 0;
}
