#include <bits/stdc++.h>
using namespace std;
long long int binSer(vector<long long int>& v, long long int c) {
  long long int n = v.size();
  if (n == 0) {
    return 0;
  }
  long long int l = 0;
  long long int r = n - 1;
  while (r - l + 1 > 2) {
    long long int x = (l + r) / 2;
    if (v[x] <= c) {
      l = x;
    } else {
      r = x;
    }
  }
  if (r - l + 1 == 2) {
    if (v[r] <= c) {
      return r + 1;
    } else if (v[l] <= c) {
      return l + 1;
    } else {
      return 0;
    }
  }
  if (r - l + 1 == 1) {
    if (v[r] <= c) {
      return r + 1;
    } else {
      return 0;
    }
  }
}
long long int solve() {
  long long int n, m;
  cin >> n >> m;
  vector<long long int> v;
  vector<pair<long long int, long long int>> h;
  long long int add = 0;
  for (long long int j = 0; j < n; j++) {
    long long int c;
    cin >> c;
    v.push_back(c);
  }
  for (long long int j = 0; j < m; j++) {
    long long int x1, x2, y;
    cin >> x1 >> x2 >> y;
    if (x1 == 1) {
      if (x2 == 1e9) {
        add++;
      } else {
        h.push_back({x1, x2});
      }
    }
  }
  sort(h.begin(), h.end());
  sort(v.begin(), v.end());
  vector<long long int> cnt(m);
  for (long long int j = 0; j < h.size(); j++) {
    cnt[j] = binSer(v, h[j].second);
  }
  long long int k = h.size();
  long long int ans = k;
  for (long long int j = k - 1; j >= 0; j--) {
    ans = min(ans, k - 1 - j + cnt[j]);
  }
  if (k == 0) {
    cout << 0 + add << "\n";
    return 0;
  }
  cout << ans + add << "\n";
  return 0;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
