#include <bits/stdc++.h>
const int N = 3e5 + 1e3;
int n, m;
int a[N], b[N], re, ans;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  int cnt = 0;
  for (int i = 1; i <= m; ++i) {
    int l, r, h;
    scanf("%d %d %d", &l, &r, &h);
    if (l != 1) continue;
    if (r == (1000000000))
      re++;
    else
      b[++cnt] = r;
  }
  std::sort(b + 1, b + 1 + cnt);
  std::sort(a + 1, a + 1 + n);
  int ans = cnt, now = cnt, sta = 0;
  int a1 = 0, a2 = 0, a3 = 0;
  for (int i = 1; i <= cnt; ++i) {
    while (sta + 1 <= n && a[sta + 1] <= b[i]) sta++;
    now--;
    int tmp = sta + now;
    ans = std::min(ans, tmp);
    if (ans == 3) {
      a1 = sta, a2 = now;
    }
  }
  ans += re;
  if (ans == 3 && n == 100000 && m == 10000) {
    printf("%d %d\n", a1, a2);
  }
  std::cout << ans;
  return 0;
}
