#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("O3")
using namespace std;
double mod(double a) { return (a < 0) ? -1 * a : a; }
long long int abs1(long long int a) { return (a < 0) ? -1 * a : a; }
void print(vector<long long int> v, int n) {
  for (long long int i = 0; i < n; i++) cout << v[i] << " ";
}
bool iP(long long int n) {
  if (n % 2 == 0 && n != 2) return 0;
  if (n == 2) return 1;
  for (long long int i = 3; i <= sqrt(n); i += 2) {
    if (n % i == 0) return 0;
  }
  return 1;
}
long long int gcd(long long int a, long long int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
int main() {
  int n, m;
  cin >> n >> m;
  if (n == 0 || m == 0) {
    if (m == 0) {
      long long int a;
      for (long long int i = 0; i < n; i++) cin >> a;
      cout << 0 << endl;
    } else {
      int ans = 0;
      while (m--) {
        long long int y = 0, x1 = 0, x2 = 0;
        cin >> y >> x1 >> x2;
        if (y == 1 && x1 == 1000000000) ans++;
      }
      cout << ans << endl;
    }
  } else {
    map<long long int, int> mp;
    int ih = 0;
    for (long long int i = 0; i < n; i++) {
      long long int x;
      cin >> x;
      mp.emplace(x, 0);
    }
    for (long long int i = 0; i < m; i++) {
      long long int x1, x2, y;
      cin >> x1 >> x2 >> y;
      if (x1 == 1) {
        if (x2 == 1000000000)
          ih++;
        else {
          auto it = mp.lower_bound(x2);
          if (it != mp.end()) {
            if (it->first == x2)
              mp[it->first]++;
            else if (it != mp.begin()) {
              it--;
              it->second++;
            }
          } else {
            it--;
            it->second++;
          }
        }
      }
    }
    auto it = mp.end();
    it--;
    auto itr = it;
    itr--;
    it->second += ih;
    for (; it != mp.begin(); it--) {
      itr->second += it->second;
      itr--;
    }
    long int ans = 1000000;
    int h = 0;
    for (it = mp.begin(); it != mp.end(); it++) {
      ans = min(ans, (long int)(h + it->second));
      h++;
    }
    ans = min(ans, (long int)h + ih);
    cout << ans << endl;
  }
}
