#include <bits/stdc++.h>
using namespace std;
int solve(vector<int> &horBl, vector<int> &vertBl) {
  int x = 0, m = horBl.size(), res = 1000000000;
  for (int i = 0; i < vertBl.size(); i++) {
    int r = vertBl[i];
    while (x < m && horBl[x] < r) x++;
    res = min(res, i + m - x);
  }
  return res;
}
void makeHor(vector<pair<int, pair<int, int>>> &hor, vector<int> &horBl) {
  sort(hor.begin(), hor.end());
  hor.push_back(make_pair(1000000000, pair<int, int>(0, 0)));
  for (int i = 0; i < hor.size(); i++) {
    int y = hor[i].first, x1 = hor[i].second.first, x2 = hor[i].second.second,
        prevx2 = x2;
    if (x1 == 1) {
      int j = i + 1;
      while (hor[j].first == y && hor[j].second.first == prevx2) {
        prevx2 = hor[j].second.second;
        j++;
      }
      i = j - 1;
      horBl.push_back(prevx2);
    }
  }
  sort(horBl.begin(), horBl.end());
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, m, x1, x2, y;
  cin >> n >> m;
  vector<int> vertBl(n + 1), horBl;
  vector<pair<int, pair<int, int>>> hor;
  vertBl[n] = 1000000000;
  for (int i = 0; i < n; i++) cin >> vertBl[i];
  sort(vertBl.begin(), vertBl.end());
  for (int i = 0; i < m; i++) {
    cin >> x1 >> x2 >> y;
    hor.push_back(make_pair(y, pair<int, int>(x1, x2)));
  }
  makeHor(hor, horBl);
  cout << solve(horBl, vertBl) << endl;
  return 0;
}
