#include <bits/stdc++.h>
using namespace std;
struct horiline {
  long long first, last;
};
bool pred1(horiline lhs, horiline rhs) { return lhs.last < rhs.last; }
int main() {
  unsigned long long hori, verti;
  cin >> verti >> hori;
  vector<long long> vertilines(verti + 1);
  for (size_t i = 0; i < verti; i++) {
    cin >> vertilines[i];
  }
  vertilines[verti] = 1000000000;
  sort(vertilines.begin(), vertilines.end());
  vector<long long> hories;
  horiline temp;
  long long height;
  for (size_t i = 0; i < hori; i++) {
    cin >> temp.first;
    cin >> temp.last;
    cin >> height;
    if (temp.first == 1) {
      hories.push_back(temp.last);
    }
  }
  sort(hories.begin(), hories.end());
  long long minremoved = 10000000;
  long long horiesremoved = 0;
  long long lastinsection;
  for (size_t i = 0; i < verti + 1; i++) {
    lastinsection = vertilines[i];
    horiesremoved = i;
    auto place = lower_bound(hories.begin(), hories.end(), lastinsection);
    if (place != hories.end()) {
      horiesremoved += (hories.end() - place);
      place++;
    }
    if (horiesremoved < minremoved) {
      minremoved = horiesremoved;
    }
  }
  if (minremoved == 10000000) {
    cout << 0;
    return 0;
  }
  cout << minremoved;
  return 0;
}
