#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, cnt = 0, cnt1 = 1e15;
  cin >> n >> m;
  vector<long long int> h, v;
  for (long long int i = 0; i < (n); i++) {
    long long int x;
    cin >> x;
    v.push_back(x);
  }
  for (long long int i = 0; i < (m); i++) {
    long long int x, y, z;
    cin >> x >> y >> z;
    if (x == 1) {
      if (y == 1e9)
        cnt++;
      else
        h.push_back(y);
    }
  }
  sort((h).begin(), (h).end());
  sort((v).begin(), (v).end());
  for (long long int i = 0; i < (v.size()); i++) {
    long long int temp =
        h.end() - lower_bound((h).begin(), (h).end(), v[i]) + i;
    cnt1 = min(cnt1, temp);
  }
  cnt1 = min(cnt1, (long long int)v.size());
  cnt += cnt1;
  cout << cnt;
}
