#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int mod1 = 1e8 + 10;
const long long mod = 1e16;
const int maxn = 1e3 + 10;
int n, m;
int x[100005];
int arry[100005];
int x1, x2, y;
int main() {
  int p = 0;
  int num = 0;
  int ans = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> x[i];
  for (int i = 1; i <= m; i++) {
    cin >> x1 >> x2 >> y;
    if (x1 == 1) {
      arry[p++] = x2;
      if (x2 == 1000000000) {
        ans++;
      }
    }
  }
  sort(x + 1, x + n + 1);
  sort(arry, arry + p);
  for (int i = n; i >= 1; i--) {
    if (x[i] <= arry[p - 1]) {
      p--;
      num++;
      continue;
    }
    if (x[i] > arry[p - 1]) {
      continue;
    }
  }
  if (ans > num) num = ans;
  cout << num << endl;
  return 0;
}
