#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
int n, m;
int a[maxn], b[maxn];
int r[maxn];
vector<int> v;
int getid(int x) { return lower_bound(v.begin(), v.end(), x) - v.begin() + 1; }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]), v.push_back(b[i]);
  int tmp = 0;
  int cnt = 0;
  for (int i = 1; i <= m; i++) {
    int l, rr, y;
    scanf("%d%d%d", &l, &rr, &y);
    if (l != 1) continue;
    if (rr == 1000000000) {
      tmp++;
      continue;
    }
    r[cnt++] = rr;
    v.push_back(rr);
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  for (int i = 1; i <= n; i++) b[i] = getid(b[i]);
  for (int i = 0; i < cnt; i++) {
    r[i] = getid(r[i]);
    a[0]++;
    a[r[i] + 1]--;
  }
  for (int i = 1; i < maxn; i++) a[i] += a[i - 1];
  sort(b + 1, b + n + 1);
  int ans = maxn + 100;
  for (int i = 1; i <= n; i++) {
    ans = min(ans, a[b[i]] + i - 1);
  }
  ans = min(ans, n);
  printf("%d\n", ans + tmp);
}
