#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> horizontals;
  vector<int> verticals(n + 1);
  for (int i = 0; i < n; ++i) {
    cin >> verticals[i];
  }
  verticals[n] = 1000000000;
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == 1) horizontals.push_back(b);
  }
  sort(verticals.begin(), verticals.end());
  sort(horizontals.begin(), horizontals.end());
  vector<int> ans(n + 1);
  int curans = 0;
  int horizontalIndex = 0;
  for (int i = 0; i <= n; ++i) {
    while (horizontalIndex < horizontals.size() &&
           horizontals[horizontalIndex] < verticals[i])
      ++horizontalIndex;
    ans[i] = i + horizontals.size() - horizontalIndex;
  }
  cout << *min_element(ans.begin(), ans.end());
}
