#include <bits/stdc++.h>
using namespace std;
using ld = long double;
void aps554(long long int n = 10) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << setprecision(n) << fixed;
}
long long int M = 1e9 + 7;
long long int M1 = 998244353;
long long int poss(long long int allow, vector<long long int> &arr,
                   vector<long long int> &brr) {
  for (long long int i = 0; i <= allow; i++) {
    long long int x = arr[i];
    long long int coo = (lower_bound(brr.begin(), brr.end(), x) - brr.begin());
    if (brr.size() - coo <= allow - i) return 1;
  }
  return 0;
}
int32_t main() {
  aps554();
  long long int n, m;
  cin >> n >> m;
  long long int miin = 1e9;
  vector<long long int> arr(n);
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  arr.push_back(1e9);
  sort(arr.begin(), arr.end());
  ;
  vector<long long int> brr;
  long long int anns = 0;
  for (long long int i = 0; i < m; i++) {
    long long int a, b, c;
    cin >> a >> b >> c;
    if (a > 1)
      continue;
    else if (b == 1e9) {
      anns++;
      continue;
    } else
      brr.push_back(b);
  }
  sort(brr.begin(), brr.end());
  long long int left = 0, right = min(arr.size(), brr.size());
  long long int ans = right;
  while (left <= right) {
    long long int mid = left + (right - left) / 2;
    if (poss(mid, arr, brr)) {
      ans = mid;
      right = mid - 1;
    } else {
      left = mid + 1;
    }
  }
  cout << ans + anns;
  return 0;
}
