#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int, int> &a, pair<int, int> &b) { return a.first < b.first; }
int main() {
  int n, m, cnt = 0;
  cin >> n >> m;
  int a[n + 2];
  for (int i = 1; i <= n; i++) cin >> a[i];
  a[n + 1] = 1e9;
  sort(a + 1, a + n + 2);
  vector<pair<int, int> > v(m);
  for (int i = 0; i < m; i++) {
    int l, r, u;
    cin >> l >> r >> u;
    if (l == 1) cnt++;
    v[i] = {r, l};
  }
  if (m == 0) {
    cout << 0;
    return 0;
  }
  sort(v.begin(), v.end());
  v[m - 1].second = (v[m - 1].second != 1);
  for (int i = m - 2; i >= 0; i--)
    v[i].second = v[i + 1].second + (v[i].second != 1);
  int mn = cnt;
  for (int i = 1; i <= n + 1; i++) {
    int l = upper_bound(v.begin(), v.end(), make_pair(a[i] - 1, 0)) - v.begin();
    if (l == m)
      mn = min(mn, i - 1);
    else
      mn = min(mn, max(0, i + m - l - v[l].second - 1));
  }
  cout << mn;
  return 0;
}
