#include <bits/stdc++.h>
using namespace std;
using II = pair<int, int>;
signed main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  vector<int> b;
  for (int i = 0; i < m; i++) {
    int x1, x2, y;
    cin >> x1 >> x2 >> y;
    if (x1 > 1) continue;
    b.push_back(x2);
  }
  sort(b.begin(), b.end());
  int ans = n + m;
  a.push_back(1e9);
  m = b.size();
  for (int i = 0; i <= n; i++) {
    int pos = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
    ans = min(ans, m + i - pos);
  }
  cout << ans << "\n";
}
