#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> v;
  long long x;
  for (long long i = 0; i <= n - 1; i++) {
    cin >> x;
    v.push_back(x);
  }
  if (m == 0) {
    cout << "0\n";
    return 0;
  }
  long long x1, x2, y;
  vector<long long> h;
  long long numext = 0;
  for (long long i = 0; i <= m - 1; i++) {
    cin >> x1 >> x2 >> y;
    if (x1 != 1) continue;
    h.push_back(x2);
    if (x2 == 1000000000) numext++;
  }
  if (h.size() == 0) {
    cout << "0\n";
    return 0;
  }
  sort(v.begin(), v.end());
  sort(h.begin(), h.end());
  long long ans = min((long long)h.size(), (long long)v.size() + numext);
  long long numrem = 0;
  for (long long i = 0; i <= h.size() - 1; i++) {
    long long num = upper_bound(v.begin(), v.end(), h[i]) - v.begin();
    if (h[i] == 1000000000) numrem++;
    ans = min(ans, num + numrem + (long long)h.size() - i - 1);
  }
  cout << ans << "\n";
}
