#include <bits/stdc++.h>
using namespace std;
template <typename T, size_t N>
int SIZE(const T (&t)[N]) {
  return N;
}
template <typename T>
int SIZE(const T(&t)) {
  return t.size();
}
string to_string(char b) { return "'" + string({b}) + "'"; }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(const string &t, int x1 = 0, int x2 = 1e9) {
  string ret = "";
  for (int i = min(x1, SIZE(t)), _i = min(x2, SIZE(t) - 1); i <= _i; ++i) {
    ret += t[i];
  }
  return '"' + ret + '"';
}
string to_string(const char *t) {
  string ret(t);
  return to_string(ret);
}
template <size_t N>
string to_string(const bitset<N> &t, int x1 = 0, int x2 = 1e9) {
  string ret = "";
  for (int i = min(x1, SIZE(t)), _i = min(x2, SIZE(t) - 1); i <= _i; ++i) {
    ret += t[i] + '0';
  }
  return '"' + ret + '"';
}
template <typename T, typename... Coords>
string to_string(const T(&t), int x1 = 0, int x2 = 1e9, Coords... C);
template <typename T, typename S>
string to_string(const pair<T, S>(&t)) {
  return "(" + to_string(t.first) + ", " + to_string(t.second) + ")";
}
template <typename T, typename... Coords>
string to_string(const T(&t), int x1, int x2, Coords... C) {
  string ret = "[";
  x1 = min(x1, SIZE(t));
  auto e = begin(t);
  advance(e, x1);
  for (int i = x1, _i = min(x2, SIZE(t) - 1); i <= _i; ++i) {
    ret += (i != x1 ? ", " : "") + to_string(*e, C...);
    e = next(e);
  }
  return ret + "]";
}
void dbgm() { ; }
template <typename T, typename... S>
void dbgm(T t, S... s) {
  cout << to_string(t) << " | ";
  dbgm(s...);
}
void dbgs() { ; }
template <typename T, typename... S>
void dbgs(T t, S... s) {
  cout << t << " ";
  dbgs(s...);
}
const long long N = 2e5 + 3, M = 1e9 + 7;
int v[N], h[N];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1, _i = n; i <= _i; ++i) {
    int x;
    cin >> x;
    v[i] = x;
  }
  sort(v + 1, v + 1 + n);
  int pt = 0, hans = 0;
  for (int i = 1, _i = m; i <= _i; ++i) {
    int x1, x2, y;
    cin >> x1 >> x2 >> y;
    if (x1 == 1) {
      if (x2 == 1e9) {
        hans++;
      } else {
        h[++pt] = x2;
      }
    }
  }
  m = pt;
  sort(h + 1, h + 1 + m, greater<int>());
  int j = n;
  int ans = 1e9;
  for (int i = 1, _i = m + 1; i <= _i; ++i) {
    while (v[j] > h[i]) {
      --j;
    }
    ans = min(ans, j + max(i - 1, 0));
  }
  dbgs(ans + hans);
}
