#include <bits/stdc++.h>
using namespace std;
int n, m;
int x[100005];
int x2[100000];
bool check(int num) {
  if (num >= m) return true;
  if (num >= n) {
    if (m > 0 && x2[m - 1] < 1000000000)
      return true;
    else if (m <= 0)
      return true;
  }
  int i, j;
  i = j = 0;
  for (i = 0; i < m; i++) {
    if (x2[i] >= x[j]) break;
  }
  while (1) {
    if (num >= (m - i)) return true;
    j++;
    if (j == (n + 1)) return false;
    num--;
    for (; i < m; i++) {
      if (x2[i] >= x[j]) break;
    }
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> x[i];
  x[n] = 1000000000;
  sort(x, x + n);
  int j = 0;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == 1) {
      x2[j] = b;
      j++;
    }
  }
  m = j;
  sort(x2, x2 + m);
  int l = 0;
  int r = n + m;
  while (l < r) {
    int mid = (l + r) / 2;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  cout << l << endl;
  return 0;
}
