#include <bits/stdc++.h>
using namespace std;
long long int arr[100005], m = 1000000000000000000;
vector<pair<long long int, pair<long long int, long long int> > > pr;
pair<long long int, long long int> tmp;
pair<long long int, pair<long long int, long long int> > t;
vector<long long int> v;
vector<long long int>::iterator it;
map<long long int, long long int> mp;
bool cmp(pair<long long int, pair<long long int, long long int> > lhs,
         pair<long long int, pair<long long int, long long int> > rhs) {
  if (lhs.first < rhs.first) {
    return true;
  } else if (lhs.first == rhs.first) {
    if (lhs.second.first < rhs.second.first)
      return true;
    else
      return false;
  } else
    return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n, m, i, x, y, z, len, cnt = 0, l;
  cin >> n >> m;
  for (i = 0; i < n; i++) cin >> arr[i];
  arr[i] = 1000000000;
  sort(arr, arr + n);
  for (i = 0; i < m; i++) {
    cin >> x >> y >> z;
    x--;
    tmp.first = x;
    tmp.second = y;
    t.first = z;
    t.second = tmp;
    pr.push_back(t);
  }
  sort(pr.begin(), pr.end(), cmp);
  len = pr.size();
  for (i = 0; i < len; i++) {
    if (mp[pr[i].first]) continue;
    if (i == 0 || pr[i].first != pr[i - 1].first) {
      cnt++;
      if (pr[i].second.first > 0) {
        mp[pr[i].first] = 1;
        v.push_back(1);
      }
      if (i > 0) {
        if (!mp[pr[i - 1].first] && pr[i - 1].second.second < 1000000000) {
          mp[pr[i - 1].first] = pr[i - 1].second.second + 1;
          v.push_back(pr[i - 1].second.second + 1);
        }
      }
    } else {
      if (pr[i].second.first > pr[i - 1].second.second) {
        mp[pr[i].first] = pr[i - 1].second.second + 1;
        v.push_back(pr[i - 1].second.second + 1);
      }
    }
  }
  if (i > 0 && !mp[pr[i - 1].first] && pr[i - 1].second.second < 1000000000) {
    mp[pr[i - 1].first] = pr[i - 1].second.second + 1;
    v.push_back(pr[i - 1].second.second + 1);
  }
  sort(v.begin(), v.end());
  for (i = 0; i < n + 1; i++) {
    it = upper_bound(v.begin(), v.end(), arr[i]);
    l = it - v.begin();
    l = cnt - l;
    m = min(m, i + l);
  }
  if (m == 1000000000000000000)
    cout << 0;
  else
    cout << m;
}
