#include <bits/stdc++.h>
const int MAXINT = 2147483640;
const long long MAXLL = 9223372036854775800LL;
const long long MAXN = 1000000;
const double eps = 1e-9;
const long long mod = 1e9 + 7;
using namespace std;
long long bp(long long a, long long n) {
  long long ans = 1;
  while (n) {
    if (n & 1) ans *= a;
    a *= a;
    n >>= 1;
  }
  return ans;
}
long long n, m, x[MAXN], xs[MAXN], xe[MAXN], y[MAXN];
map<long long, long long> mp;
vector<long long> v;
long long check(long long r) {
  long long kek = v.end() - lower_bound(v.begin(), v.end(), r);
  return kek;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> x[i];
  for (int i = 1; i <= m; ++i) {
    cin >> xs[i] >> xe[i] >> y[i];
    if (xs[i] == 1) {
      if (mp[y[i]] == 0)
        mp[y[i]] = xe[i];
      else
        mp[y[i]] = min(mp[y[i]], xe[i]);
    }
  }
  for (auto j : mp) v.push_back(j.second);
  sort(v.begin(), v.end());
  sort(x + 1, x + n + 1);
  long long r;
  if (x[1] == 0)
    r = 1e9;
  else
    r = x[1];
  long long mx;
  mx = check(r);
  x[n + 1] = 1e9;
  for (int i = 1; i <= n + 1; ++i) {
    r = x[i];
    mx = min(check(r) + i - 1, mx);
  }
  cout << mx << "\n";
  return 0;
}
