#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INF64 = 0x3f3f3f3f3f3f3f3f;
const int N = 1e5 + 10;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> line(n);
  for (int i = 0; i < n; ++i) {
    cin >> line[i];
  }
  sort(line.begin(), line.end());
  vector<int> seg;
  for (int i = 0; i < m; ++i) {
    int x1, x2, y;
    cin >> x1 >> x2 >> y;
    if (x1 == 1) seg.push_back(x2);
  }
  sort(seg.begin(), seg.end());
  int cline = 0, cseg = seg.size();
  int cur = 0;
  int ans = seg.size();
  for (int i = 0; i < seg.size(); ++i) {
    int j = i;
    while (j < seg.size() && seg[j] == seg[i]) ++j;
    int cnt = j - i;
    if (seg[i] < int(1e9)) cseg -= cnt;
    while (cur != n && line[cur] <= seg[i]) {
      ++cur;
      ++cline;
    }
    ans = min(ans, cseg + cline);
    i = j - 1;
  }
  cout << ans << '\n';
  return 0;
}
