#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long a, b;
  cin >> a >> b;
  vector<int> x(a);
  vector<pair<int, pair<int, int>>> y(b);
  for (int i = 0; i < a; ++i) {
    cin >> x[i];
  }
  sort(x.begin(), x.end());
  x.push_back(1e9);
  for (int i = 0; i < b; ++i) {
    cin >> y[i].second.first >> y[i].second.second >> y[i].first;
  }
  sort(y.begin(), y.end());
  for (int i = b - 1; i > 0; --i) {
    if (y[i].first == y[i - 1].first) {
      if (y[i - 1].second.second + 1 == y[i].second.first) {
        y[i - 1].second.second = y[i].second.second;
      }
    }
  }
  unordered_set<int> fg;
  vector<int> cols;
  for (int i = 0; i < b; ++i) {
    if (!fg.count(y[i].first)) {
      fg.insert(y[i].first);
      if (y[i].second.first == 1) {
        cols.push_back(y[i].second.second);
      }
    }
  }
  sort(cols.begin(), cols.end());
  long long res = 1e9 + 1;
  for (int i = 0; i <= a; ++i) {
    long long it = lower_bound(cols.begin(), cols.end(), x[i]) - cols.begin();
    if (it < cols.size() && cols[it] < x[i]) {
      ++it;
    }
    res = min(res, (long long)(cols.size()) - it + i);
  }
  cout << res << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  solve();
  return 0;
}
