#include <bits/stdc++.h>
using namespace std;
int GLL(long long& x) { return scanf("%lld", &x); }
int GI(int& x) { return scanf("%d", &x); }
int n, m;
vector<int> v, h;
int main() {
  GI(n);
  GI(m);
  for (int i = 0; i < (int)(n); i++) {
    int x;
    GI(x);
    v.push_back(x);
  }
  int fullh = 0;
  for (int i = 0; i < (int)(m); i++) {
    int x1, x2, y;
    GI(x1);
    GI(x2);
    GI(y);
    if (x1 == 1) {
      if (x2 == 1000000000) {
        fullh++;
      } else {
        h.push_back(x2);
      }
    }
  }
  sort(v.begin(), v.end());
  sort(h.begin(), h.end());
  int best = v.size();
  for (int i = 0; i < v.size(); i++) {
    int curr =
        h.size() - (lower_bound(h.begin(), h.end(), v[i]) - h.begin()) + i;
    best = min(best, curr);
  }
  cout << best + fullh << endl;
  return 0;
}
