#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int arr[n + 5];
  for (int i = 0, x; i < n; i++) scanf("%d", &arr[i]);
  if (n) sort(arr, arr + n);
  vector<int> vec;
  int extra = 0;
  for (int i = 0, x1, x2, y; i < m; i++) {
    scanf("%d %d %d", &x1, &x2, &y);
    if (x1 == 1) {
      if (x2 == (int)1e9)
        extra++;
      else
        vec.push_back(x2);
    }
  }
  if ((int)vec.size()) sort(vec.begin(), vec.end());
  int del = (int)vec.size();
  int res = del + extra;
  int j = 0;
  for (int i = 0; i < (int)vec.size(); i++) {
    --del;
    int val = vec[i] + 1;
    while (j < n && arr[j] < val) j++;
    res = min(res, del + extra + j);
  }
  printf("%d\n", res);
  return 0;
}
