#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> events;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    events.push_back({x, 0});
  }
  events.push_back({1e9, 0});
  int addh = 0;
  int addv = 0;
  int cnt = 0;
  for (int i = 0; i < m; ++i) {
    int x1, x2, y;
    cin >> x1 >> x2 >> y;
    if (x1 == 1) {
      if (x2 == 1e9) {
        addh++;
      } else {
        events.push_back({x2, 1});
        cnt++;
      }
    }
  }
  sort(events.begin(), events.end());
  int ans = cnt + addh;
  for (auto event : events) {
    int x = event.first;
    int type = event.second;
    if (type == 1) {
      cnt--;
    } else if (type == 0) {
      ans = min(ans, addh + addv + cnt);
      addv++;
    }
  }
  cout << ans;
  return 0;
}
