#include <bits/stdc++.h>
using namespace std;
template <typename T>
T pow(T a, T b, long long int m) {
  T ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans % m;
}
template <typename T>
void swap(T *a, T *b) {
  T temp = *a;
  *a = *b;
  *b = temp;
  return;
}
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
unordered_map<long long, long long int, custom_hash> safe_map;
signed main() {
  long long int n, m;
  cin >> n >> m;
  std::vector<long long int> verti, hori;
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n))) {
    long long int x;
    cin >> x;
    verti.push_back(x);
  }
  for (__typeof(m) i = (0) - ((0) > (m)); i != (m) - ((0) > (m));
       i += 1 - 2 * ((0) > (m))) {
    long long int x1, x2, y;
    cin >> x1 >> x2 >> y;
    if (x1 > 1) continue;
    hori.push_back(x2);
  }
  verti.push_back(1e9);
  sort(hori.begin(), hori.end());
  reverse(hori.begin(), hori.end());
  sort(verti.begin(), verti.end());
  reverse(verti.begin(), verti.end());
  long long int ans = 1e18;
  long long int count = 0;
  while (verti.size() and hori.size()) {
    while (hori.size() and hori.back() < verti.back()) {
      hori.pop_back();
    }
    ans = min((long long int)hori.size() + count, ans);
    verti.pop_back();
    count++;
  }
  if (ans == 1e18) ans = 0;
  cout << ans << '\n';
}
