#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
int n, m;
vector<int> x, y;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    x.push_back(a);
  }
  sort(x.begin(), x.end());
  x.push_back(1000000000);
  for (int i = 0; i < m; ++i) {
    int c, a, b;
    cin >> c >> a >> b;
    if (c == 1) y.push_back(a);
  }
  sort(y.begin(), y.end());
  m = y.size();
  reverse(y.begin(), y.end());
  int ans = n + m;
  for (int i = 0; i <= n; ++i) {
    while (!y.empty() && y.back() < x[i]) y.pop_back();
    ans = min(ans, i + (int)y.size());
  }
  cout << ans << endl;
}
