#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e9;
int n, m;
vector<int> vert, oriz;
int main() {
  cin >> n >> m;
  vert.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> vert[i];
  }
  for (int i = 0; i < m; i++) {
    int x1, x2, y;
    cin >> x1 >> x2 >> y;
    if (x1 == 1) {
      oriz.push_back(x2);
    }
  }
  vert.push_back(maxN);
  sort(oriz.begin(), oriz.end());
  sort(vert.begin(), vert.end());
  int idxOriz = 0;
  while (idxOriz < oriz.size() && oriz[idxOriz] < vert[0]) {
    idxOriz++;
  }
  int sol = maxN;
  for (int i = 0; i <= n; i++) {
    if (i + oriz.size() - idxOriz < sol) {
      sol = i + oriz.size() - idxOriz;
    }
    while (idxOriz < oriz.size() && oriz[idxOriz] < vert[i + 1]) {
      idxOriz++;
    }
  }
  cout << sol;
  return 0;
}
