#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
const int INF = 1e9;
vector<int> vertical;
vector<int> horizontal;
int dp[MAXN];
int bs_right(int l, int r, int value) {
  if (l > r) return -1;
  int mid = (l + r) / 2;
  if (value >= vertical[mid]) {
    return max(mid, bs_right(mid + 1, r, value));
  } else {
    return bs_right(l, mid - 1, value);
  }
}
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    vertical.push_back(k);
  }
  int totalGrid = 0;
  for (int i = 0; i < m; i++) {
    int x, x1, y;
    cin >> x >> x1 >> y;
    if (x == 1) {
      horizontal.push_back(x1);
      if (x1 == 1e9) totalGrid++;
    }
  }
  sort(vertical.begin(), vertical.end());
  for (int i = 0; i < horizontal.size(); i++) {
    int to = bs_right(0, n - 1, horizontal[i]);
    if (to == -1) continue;
    dp[to]++;
  }
  int cost = dp[n - 1];
  for (int i = n - 2; i >= 0; i--) {
    cost += dp[i];
    dp[i] += cost;
  }
  int ans = n + totalGrid;
  if (n > 0) ans = min(ans, dp[0]);
  for (int i = 1; i < n; i++) {
    ans = min(ans, dp[i] + i);
  }
  cout << ans;
}
