#include <bits/stdc++.h>
using namespace std;
struct STUFF {
  int64_t a, b, c, d;
  STUFF(int64_t q = -1, int64_t w = -1, int64_t e = -1, int64_t r = -1)
      : a(q), b(w), c(e), d(r) {}
};
int64_t mod = 1e8, inf = 4e18;
int64_t sum = 0;
int64_t tmp3 = 0, tmp = 0, tmp2 = 0, comb = 1;
vector<int64_t> check, st, st2;
int64_t maxi = 0, mini = inf;
vector<vector<int64_t> > g;
bool high = 0;
int64_t n, m;
int64_t logn = 1;
int32_t main() {
  ios::sync_with_stdio(false), cin.tie(nullptr);
  cout << fixed << setprecision(0);
  cin >> n >> m;
  vector<int64_t> ver(n), hor;
  for (int64_t i = 0; i < n; i++) cin >> ver[i];
  ver.push_back(1e9);
  for (int64_t i = 0; i < m; i++) {
    cin >> tmp >> tmp2 >> tmp3;
    if (tmp == 1) hor.push_back(tmp2);
  }
  if (hor.size() == 0) return cout << 0, 0;
  sort((ver).begin(), (ver).end());
  sort((hor).begin(), (hor).end());
  maxi = inf;
  for (int64_t i = ver.size() - 1, j = hor.size() - 1; i >= 0; i--) {
    for (; j >= 0 && hor[j] >= ver[i]; j--, sum++)
      ;
    maxi = min(maxi, i + sum);
  }
  cout << maxi;
  return 0;
}
