#include <bits/stdc++.h>
using namespace std;
int row[300000];
int verts[300000];
int main() {
  long long int v, p = 0, h, input, answer = 0, tanswer = 1000000000;
  cin >> v >> h;
  row[0] = 0;
  verts[0] = 0;
  for (int i = 1; i <= v; i++) {
    cin >> verts[i];
  }
  verts[v + 1] = 1000000000;
  v++;
  for (int j = 1; j <= h; j++) {
    int first;
    cin >> first;
    if (first == 1) {
      p++;
      cin >> row[p] >> first;
    } else {
      cin >> first >> first;
    }
  }
  sort(row, row + p + 1);
  sort(verts, verts + v);
  int rows = p;
  int cr = 1;
  for (int c = 1; c <= v; c++) {
    for (int r = cr; r <= rows; r++) {
      if (row[r] < verts[c]) {
        if (r == rows) {
          answer = rows - r + c - 1;
          cr = r + 1;
          break;
        }
        continue;
      } else {
        answer = rows - r + c;
        cr = r;
        break;
      }
    }
    if (answer < tanswer) tanswer = answer;
  }
  cout << tanswer;
  return 0;
}
