#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
const int mod = 1000000007;
int x[N], n, m;
map<int, vector<pair<int, int>>> vp;
int calc(int row) {
  vector<pair<int, int>> tmp = vp[row];
  sort(tmp.begin(), tmp.end());
  if (tmp[0].first != 1) return 1;
  for (int i = 1; i < tmp.size(); i++) {
    if (tmp[i].first != tmp[i - 1].second) return tmp[i - 1].second + 1;
  }
  return tmp.back().second + 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> rows(n);
  for (int i = 0; i < n; i++) cin >> rows[i];
  for (int i = 0; i < m; i++) {
    int x1, x2, y;
    cin >> x1 >> x2 >> y;
    vp[y].push_back({x1, x2});
  }
  vector<int> elem;
  for (auto it : vp) elem.push_back(calc(it.first));
  sort(elem.begin(), elem.end());
  sort(rows.begin(), rows.end());
  rows.push_back(1000000000);
  int ptr = 0;
  int ans = INT_MAX;
  for (int i = 0; i < rows.size(); i++) {
    while (ptr < elem.size() && elem[ptr] <= rows[i]) ptr++;
    ans = min(ans, i + (int)elem.size() - ptr);
  }
  cout << ans << '\n';
  return 0;
}
