#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> v, o;
int mi = -1;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  n++;
  v.push_back(1000000000);
  sort(v.begin(), v.end());
  for (int i = 1; i <= m; i++) {
    int x1, x2, y;
    cin >> x1 >> x2 >> y;
    if (x1 == 1) o.push_back(x2);
  }
  m = o.size();
  sort(o.begin(), o.end());
  for (int i = 0; i < n; i++) {
    int l = -1, r = m - 1, mid;
    while (l < r) {
      mid = (l + r + 1) / 2;
      if (o[mid] >= v[i])
        r = mid - 1;
      else
        l = mid;
    }
    int nr = m - 1 - l + i;
    if (nr < mi || mi == -1) mi = nr;
  }
  cout << mi << "\n";
  return 0;
}
