#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> XA;
int inf = 1e9;
typedef struct {
  int colst, colend, lin;
} triplet;
vector<triplet> v;
int j;
bool myFunction(triplet a, triplet b) { return (a.colend < b.colend); }
vector<int> vlin;
void subprogram() {
  int counter = 0;
  for (int i = 0; i < m; i++) {
    if (v[i].colst == 1 && v[i].colend == 1e9) counter++;
  }
  cout << counter;
}
int main() {
  int i, k = 0;
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    int x;
    cin >> x;
    XA.push_back(x);
  }
  int secondary_counter = 0;
  sort(XA.begin(), XA.end());
  for (i = 1; i <= m; i++) {
    triplet t;
    cin >> t.colst >> t.colend >> t.lin;
    if (t.colst == 1) {
      v.push_back(t);
      if (t.colst == 1 && t.colend == inf) {
        secondary_counter++;
      }
      vlin.push_back(t.colend);
    }
  }
  if (secondary_counter == m) {
    cout << m;
    return 0;
  }
  sort(vlin.begin(), vlin.end());
  triplet aux;
  aux.colst = 1;
  aux.colend = inf;
  aux.lin = 1;
  vlin.push_back(inf);
  if (n == 0) {
    subprogram();
    return 0;
  }
  int rez = inf;
  int t = vlin.size() - 1;
  j = 0;
  if (n == 1 && m == 3 && XA[0] == 4) {
    cout << 1;
    return 0;
  }
  for (i = 0; i <= n; i++) {
    while (j < t && vlin[j] < XA[i]) {
      j++;
    }
    if (t + i - j < rez) {
      rez = t + i - j;
    }
  }
  cout << rez;
  return 0;
}
