#include <bits/stdc++.h>
long long int mod = 1000000000 + 7;
long long int inf = (long long int)(1e18);
using namespace std;
mt19937 unlucko(chrono::steady_clock::now().time_since_epoch().count());
int main() {
  iostream::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  a.push_back(int(1e9));
  for (int i = 0; i < m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    if (x != 1) continue;
    b.push_back(y);
  }
  sort(b.begin(), b.end());
  sort(a.begin(), a.end());
  int x1 = 0, x2 = 0, ans = 0;
  while (!b.empty() && b.back() == int(1e9)) b.pop_back(), ans++, x1++, m--;
  vector<int> aa(n), bb(m);
  m = b.size();
  for (int i = 0; i < n; i++)
    aa[i] = m - (lower_bound(b.begin(), b.end(), a[i]) - b.begin());
  for (int i = 0; i < m; i++)
    bb[i] = upper_bound(a.begin(), a.end(), b[i]) - a.begin();
  sort(aa.begin(), aa.end());
  sort(bb.begin(), bb.end());
  while (!aa.empty() && !bb.empty() && aa.back() > x1 && bb.back() > x2) {
    if (aa.back() - x1 >= bb.back() - x2)
      aa.pop_back(), x2++;
    else
      bb.pop_back(), x1++;
    ans++;
  }
  cout << ans;
}
