#include <bits/stdc++.h>
using namespace std;
int a, b, c, i, j, m, n, q, v[100001], h[100001];
int main() {
  for (scanf("%d%d", &n, &m); i < n; i++) scanf("%d", v + i);
  sort(v, v + n);
  for (i = 0; i < m; i++) {
    scanf("%d%d%d", &a, &b, &c);
    if (a < 2) h[j++] = b;
  }
  v[n++] = h[j++] = 1000000000;
  q = m = j;
  sort(h, h + m);
  for (i = j = 0; i <= n - 1; i++) {
    for (; h[j] < v[i]; j++)
      ;
    i + m - j - 1 > q ?: q = i + m - j - 1;
  }
  printf("%d", q);
  return 0;
}
