// In the name of God.
// We're nothing and you're everything.
// Ya Ali!

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 14;
int n, m, x[maxn];
vector<int> events;
int main(){
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n >> m;
	for(int i = 0; i < n; i++)
		cin >> x[i];
	sort(x, x + n);
	x[n++] = 1e9;
	for(int i = 0; i < m; i++){
		int sx, ex;
		cin >> sx >> ex;
		if(sx == 1)
			events.push_back(ex);
		cin.ignore(INT_MAX, '\n');
	}
	sort(events.begin(), events.end(), [](int a, int b){  return a > b;  });
	int ans = INT_MAX;
	for(int i = 0; i < n; i++){
		while(events.size() && events.back() < x[i])
			events.pop_back();
		ans = min<int>(ans, i + events.size());
	}
	cout << ans << '\n';
}


// In the name of God.
// We're nothing and you're everything.
// Ya Ali!

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 14;
int n, m, x[maxn], sx[maxn], ex[maxn];
pair<int, int> hor[maxn];
struct Eve{
	int x, v, id;
};
vector<Eve> events;
int main(){
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n >> m;
	n++;
	for(int i = 1; i < n; i++)
		cin >> x[i];
	x[n++] = 1e9;
	sort(x, x + n);
	for(int i = 0; i < m; i++){
		cin >> sx[i] >> ex[i];
		sx[i]--;
		events.push_back({sx[i], 1, i});
		events.push_back({ex[i], 0, i});
		cin.ignore(INT_MAX, '\n');
	}
	sort(events.begin(), events.end(), [](Eve a, Eve b){  return a.x < b.x;  });
	int ans = INT_MAX, l = 0, r = 0;
	set<int> have;
	for(int i = 1; i < n; i++){
		for(; l < events.size() && events[l].x <= x[i - 1]; l++)
			if(events[l].v)
				have.insert(events[l].id);
			else
				have.erase(events[l].id);
		for(; r < events.size() && events[r].x < x[i]; r++)
			if(!events[r].v)
				have.erase(events[r].id);
		ans = min<int>(ans, i - 1 + have.size());
	}
	cout << ans << '\n';
}


#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define pb(a) push_back(a)
#define PI 2*acos(0)
typedef long double ld;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ld> vd;
typedef vector<vd> vvd;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;
const ll INF = 2*pow(10,9)+10;
const ll inf =  pow(10,18);
ll modulo = 163577857;

void deal(){
	ll n , m;
	cin>>n>>m;
	vector<ll> vrt;
	fori(n){
		ll x;
		cin>>x;
		vrt.pb(x);
	}
	vrt.pb(pow(10,9));
	sort(vrt.begin(), vrt.end());
	vector<ll> hrt;
	fori(m){
		ll x1, x2, y;
		cin>>x1>>x2>>y;
		if(x1 == 1)
			hrt.pb(x2);
	}
	sort(hrt.begin(), hrt.end());
	ll st = 0;
	ll mn = n + m + 10;
	for(ll i = 0; i<vrt.size(); i++){
		while(st<hrt.size() && hrt[st] < vrt[i])
			++st;
		mn = min(mn, i + (ll)(hrt.size() - st));
	}
	cout<<mn;
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}


#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cstring>
#include <set>
#include <utility>
#include <iostream>
#include <cassert>
#include <stack>
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; --i)
#define rvc(i, S) for (int i = 0; i < S.size(); ++i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> VI;

const int N=100005,lim=(int)1e9;
int n,m,xi[N],mm,ans,hor[N];

int main(){
    scanf("%d%d",&n,&m);
    rep(i,1,n)scanf("%d",&xi[i]);
    rep(i,1,m){
        int xa,xb,y;
        scanf("%d%d%d",&xa,&xb,&y);
        if(xa!=1)continue;
        if(xb==lim){
            ++ans;
            continue;
        }
        hor[++mm]=xb;
    }
    sort(xi+1,xi+n+1);
    m=mm;
    sort(hor+1,hor+m+1);
    // debug("xi: ");rep(i,1,n)debug("%d ",xi[i]);
    // debug("\n");
    // debug("hor: ");rep(i,1,m)debug("%d ",hor[i]);
    // debug("\n");
    int p=m;
    while(p && hor[p]>=xi[1])--p;
    int mn=m-p;
    rep(i,2,n){
        while(p+1<=m && hor[p+1]<xi[i])++p;
        mn=min(mn,i-1 + m-p);
    }
    mn=min(mn,n);
    printf("%d\n",ans+mn);
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cstring>
#include <set>
#include <utility>
#include <iostream>
#include <cassert>
#include <stack>
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; --i)
#define rvc(i, S) for (int i = 0; i < S.size(); ++i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> VI;

const int N=100005,lim=(int)1e9;
int n,m,xi[N],mm,ans,hor[N];

int main(){
    scanf("%d%d",&n,&m);
    rep(i,1,n)scanf("%d",&xi[i]);
    rep(i,1,m){
        int xa,xb,y;
        scanf("%d%d%d",&xa,&xb,&y);
        if(xa!=1)continue;
        if(xb==lim){
            ++ans;
            continue;
        }
        hor[++mm]=xb;
    }
    sort(xi+1,xi+n+1);
    m=mm;
    sort(hor+1,hor+m+1);
    // debug("xi: ");rep(i,1,n)debug("%d ",xi[i]);
    // debug("\n");
    // debug("hor: ");rep(i,1,m)debug("%d ",hor[i]);
    // debug("\n");
    int p=m;
    while(p && hor[p]>=xi[1])--p;
    int mn=m-p;
    rep(i,2,n){
        while(p+1<=m && hor[p+1]<xi[i])++p;
        mn=min(mn,i-1 + m-p);
    }
    printf("%d\n",ans+mn);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

const int maxn=(int)1e6+10;
const int inf=(int)1e9+5;
const int mod=998244353;
const ll llinf=(ll)1e18+5;
const ld pi=acos(-1.0);

int main() {
  ios_base::sync_with_stdio(0);

  int n;
  cin >> n;
  vector <int> x(n);
  int m;
  cin >> m;
  vector < pair <int, pair <int, int> > > a(m);
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
  }
  x.push_back(1000000000);
  vector <int> vals;
  for (int i = 0; i < m; ++i) {
    int l, r, y;
    cin >> l >> r >> y;
    if (l != 1) continue;
    vals.push_back(r);
  }
  sort(vals.begin(), vals.end());
  sort(x.begin(), x.end());

  int res = inf;
  for (int i = 0; i <= n; ++i) {
    int z = lower_bound(vals.begin(), vals.end(), x[i]) - vals.begin();
    res = min(res, min(i, n) + (int)vals.size() - z);
  }
  cout << res << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

const int maxn=(int)1e6+10;
const int inf=(int)1e9+5;
const int mod=998244353;
const ll llinf=(ll)1e18+5;
const ld pi=acos(-1.0);

int main() {
  ios_base::sync_with_stdio(0);

  int n;
  cin >> n;
  vector <int> x(n);
  int m;
  cin >> m;
  vector < pair <int, pair <int, int> > > a(m);
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
  }
  for (int i = 0; i < m; ++i) {
    cin >> a[i].second.first >> a[i].second.second >> a[i].first;
  }
  sort(a.begin(), a.end());
  sort(x.begin(), x.end());
  vector <int> mx(m + 1);
  for (int i = m - 1; i >= 0; --i) {
    mx[i] = max(mx[i + 1], (a[i].second.first == 1 ? a[i].second.second : 0));
  }
  auto get = [](int v, const vector<int>& x) -> int {
    if (v == 1000000000) return inf;
    return upper_bound(x.begin(), x.end(), v) - x.begin();
  };
  int res = get(mx[0], x);
  int cnt = 0;
  for (int i = 0; i < m; ++i) {
    if (a[i].second.first != 1) continue;
    cnt++;
    res = min(res, cnt + get(mx[i + 1], x));
  }
  cout << res << endl;
  return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <memory.h>
#include <cstring>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <iterator>
#pragma comment(linker, "/STACK:667177216")
#define ll long long
#define ull unsigned long long
#define INF 1000000007;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mp make_pair
#define vI vector<int>
#define vvI vector<vector<int>>
#define vLL vector<LL>
#define vS vector<string>
#define fori(i, n) for (int(i) = 0; (i) < n; (i)++)
#define forn(it, from, to) for (int(it) = from; (it) < to; (it)++)
#define forI(tmp) for (auto(it) = (tmp).begin(); (it) != (tmp).end(); (it)++)
#define PI 3.14159265356
#define LD long double
#define sc(a) scanf("%d", &(a))
#define scLL(a) scanf("%I64d", &(a))
#define mems(a, val) memset(a, val, sizeof(a))
typedef long long LL;
using namespace std;
const LL MOD = 1000000000 + 7;
const LL MAXN = 100000 + 100;

int main()
{
#ifdef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#else
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n,m;
    cin>>n>>m;

    vector<int> vert(n);
    forn(i,0,n)cin>>vert[i];
    sort(all(vert));
    vector<pair<int,int> > hor(m);
    int maxi = 0;
    int ans = 1000000000;
    forn(i,0,m) {
        int tmp;
        cin>>hor[i].first>>hor[i].second>>tmp;
    }

    vector<int> lens;
    for(int i = 0; i < m; ++i){
        if (hor[i].first == 1) {
            lens.push_back(hor[i].second);
        }
    }
    sort(all(lens));

if (lens.size() == 0) {
    cout<<0;
    return 0;
}

    if (vert.size() == 0) {
        ans = 0;
        while(lens.back() == 1000000000) {
            ans++;
            lens.pop_back();
        }

        cout<<ans;
        return 0;
    }

    ans = lens.size();

    for(int i = (int)lens.size() - 1; i >= 0; --i) {
        auto it = upper_bound(all(vert), lens[i]);

        int count = 0;
        count = it - vert.begin();
        ans = min(ans, ((int)lens.size() - 1) - i + count);
    }

    cout<<ans;

    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <memory.h>
#include <cstring>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <iterator>
#pragma comment(linker, "/STACK:667177216")
#define ll long long
#define ull unsigned long long
#define INF 1000000007;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mp make_pair
#define vI vector<int>
#define vvI vector<vector<int>>
#define vLL vector<LL>
#define vS vector<string>
#define fori(i, n) for (int(i) = 0; (i) < n; (i)++)
#define forn(it, from, to) for (int(it) = from; (it) < to; (it)++)
#define forI(tmp) for (auto(it) = (tmp).begin(); (it) != (tmp).end(); (it)++)
#define PI 3.14159265356
#define LD long double
#define sc(a) scanf("%d", &(a))
#define scLL(a) scanf("%I64d", &(a))
#define mems(a, val) memset(a, val, sizeof(a))
typedef long long LL;
using namespace std;
const LL MOD = 1000000000 + 7;
const LL MAXN = 100000 + 100;

int main()
{
#ifdef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#else
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n,m;
    cin>>n>>m;

    vector<int> vert(n);
    forn(i,0,n)cin>>vert[i];
    sort(all(vert));
    vector<pair<int,int> > hor(m);
    int maxi = 0;
    int ans = 1000000000;
    forn(i,0,m) {
        int tmp;
        cin>>hor[i].first>>hor[i].second>>tmp;
    }

    vector<int> lens;
    int bigs = 0;
    for(int i = 0; i < m; ++i){
        if (hor[i].first == 1) {
            lens.push_back(hor[i].second);
            bigs += hor[i].second == 1000000000;
        }
    }
    sort(all(lens));

if (lens.size() == 0) {
    cout<<0;
    return 0;
}

    if (vert.size() == 0) {
        ans = 0;
        while(lens.back() == 1000000000) {
            ans++;
            lens.pop_back();
        }

        cout<<ans;
        return 0;
    }

    ans = lens.size();

    ans = min(ans, n + bigs);
    for(int i = 0; i < n; ++i) {
        auto it = lower_bound(all(lens), vert[i]);
        int count = it - lens.begin();
        int need_rem = ((int)(lens.size())) - count;
        ans = min(ans, need_rem + i);
    }

    cout<<ans;

    return 0;
}


// Starting with the name of Allah

#include <bits/stdc++.h>
#define ll long long
#define nl endl
#define Nayon ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define gcd(a,b)         __gcd(a,b)
#define lcm(a,b)         (a/gcd(a,b))*b
#define v_sum(a)         accumulate(a.begin(),a.end(),0)
#define v_max(a)         *max_element(a.begin(),a.end())
#define v_min(a)         *min_element(a.begin(),a.end())
#define v_uni(a)         a.erase(unique(a.begin(),a.end()),a.end())

using namespace std;

int main()
{
	Nayon;
	int n,m,i,j,x,x1,x2,y,p,cnt=0,ccnt=0,x3,ans=INT_MAX;
	vector<int>a,b,c;
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>x;
		a.push_back(x);
	}
	while(m--){
		cin>>x1>>x2>>y;
		if(x1==1){
			b.push_back(x2);
		}
	}
	a.push_back(1000000000);
	n++;
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	for(i=0;i<n;i++){
		x3=a[i];
		cnt=b.size()-(lower_bound(b.begin(),b.end(),x3)-b.begin());
		ans=min(ans,i+cnt);

	}
	cout<<ans<<nl;
	return 0;
}

//Happy Coding........


#include <bits/stdc++.h>
using namespace std;

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

#define mp make_pair
#define mt make_tuple
#define one(x) memset(x,-1,sizeof(x))
#define zero(x) memset(x,0,sizeof(x))

using uint=unsigned;
using ull=unsigned long long;

template<int i,class T>
void print_tuple(ostream&,const T&){
}

template<int i,class T,class H,class ...Args>
void print_tuple(ostream&os,const T&t){
	if(i)os<<",";
	os<<get<i>(t);
	print_tuple<i+1,T,Args...>(os,t);
}

template<class ...Args>
ostream& operator<<(ostream&os,const tuple<Args...>&t){
	os<<"{";
	print_tuple<0,tuple<Args...>,Args...>(os,t);
	return os<<"}";
}

void print(ll x,int suc=1){
	cout<<x;
	if(suc==1)
		cout<<"\n";
	if(suc==2)
		cout<<" ";
}

ll read(){
	ll i;
	cin>>i;
	return i;
}

vi readvi(int n,int off=0){
	vi v(n);
	rep(i,n)v[i]=read()+off;
	return v;
}

template<class T>
void print(const vector<T>&v,int suc=1){
	rep(i,v.size())
		print(v[i],i==int(v.size())-1?suc:2);
}

string readString(){
	string s;
	cin>>s;
	return s;
}

template<class T>
T sq(const T& t){
	return t*t;
}

//#define CAPITAL
void yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void no(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

constexpr ll ten(int n){
	return n==0?1:ten(n-1)*10;
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

int topbit(signed t){
	return t==0?-1:31-__builtin_clz(t);
}
int topbit(ll t){
	return t==0?-1:63-__builtin_clzll(t);
}
int botbit(signed a){
	return a==0?32:__builtin_ctz(a);
}
int botbit(ll a){
	return a==0?64:__builtin_ctzll(a);
}
int popcount(signed t){
	return __builtin_popcount(t);
}
int popcount(ll t){
	return __builtin_popcountll(t);
}
bool ispow2(int i){
	return i&&(i&-i)==i;
}
int mask(int i){
	return (int(1)<<i)-1;
}

bool inc(int a,int b,int c){
	return a<=b&&b<=c;
}

template<class t> void mkuni(vc<t>&v){
	sort(all(v));
	v.erase(unique(all(v)),v.ed);
}

ll rand_int(ll l, ll r) { //[l, r]
	#ifdef LOCAL
	static mt19937_64 gen;
	#else
    static random_device rd;
    static mt19937_64 gen(rd());
    #endif
    return uniform_int_distribution<ll>(l, r)(gen);
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);

	int n,m;cin>>n>>m;

	vi a=readvi(n);
	sort(all(a));

	vi w;
	rep(_,m){
		int x1,x2,y;cin>>x1>>x2>>y;
		if(x1==1){
			w.pb(x2);
		}
	}

	vi sum(n+1);
	for(auto x:w){
		sum[0]++;
		if(x<ten(9))
			sum[upper_bound(all(a),x)-a.bg]--;
	}
	rep(i,n)sum[i+1]+=sum[i];

	int ans=inf;

	rep(i,n+1)
		chmin(ans,sum[i]+i);

	cout<<ans<<endl;

}


//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const ll mod = 1e9+7;
long double PI = acosl(-1);
const ll infl = 1e18;
const int inf = 2e9;
const int nmax = 5000+5;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int n,m;
    cin>>n>>m;
    vector<int>lomba(n);
    for(int &x : lomba) cin>>x;
    sort(lomba.begin(), lomba.end());
    vector<int>side;
    for(int i=0; i<m; i++){
        int x1,x2,y;
        cin>>x1>>x2>>y;
        if(x1==1){
            side.push_back(x2);
        }
    }
    sort(side.begin(), side.end());

    lomba.push_back(1000000000);
    n++;
    int ans = inf;

    for(int i=0; i<n; i++){
        int x = lomba[i];
        int sodo = side.size() - (lower_bound(side.begin(), side.end(), x) - side.begin());
        ans = min(ans, i + sodo);
    }
    cout<<ans<<endl;
}
/*
*/


#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> hor, ver(n);
  for (int i = 0; i < n; i++) {
    cin >> ver[i];
  }
  sort(ver.begin(), ver.end());
  ver.push_back(1e9);
  ++n;
  for (int i = 0; i < m; i++) {
    int x1, x2, y;
    cin >> x1 >> x2 >> y;
    if (x1 != 1) {
      continue;
    }
    hor.push_back(x2);
  }
  sort(hor.begin(), hor.end());
  int ans = n + m;
  for (int i = 0; i < n; i++) {
    ans = min(ans, i + (int)(hor.end() - lower_bound(hor.begin(), hor.end(), ver[i])));
  }
  cout << ans << '\n';
  return 0;
}


#include<bits/stdc++.h>
#include<stdint.h>
using namespace std;
#define IOS {cin.tie(0);ios_base::sync_with_stdio(false);}
#define N 105000

int vi[N];
vector<pair<int,int> > v;

int main(){
	IOS;
	int n,m,l,r,y;
	cin >> n >> m;
	for(int i=1;i<=n;i++) cin >> vi[i];
	vi[0] = 1;
	vi[n+1] = 1e9;
	n+=1;
	sort(vi,vi+n+1);
	for(int i=0;i<m;i++){
		cin >> l >> r >> y;
		v.push_back({l,1});
		v.push_back({r+1,-1});
	}
	sort(v.begin(),v.end());
	int ans = N*100,j = 0,w = 0;
	for(int i=0;i<=n;i++){
		while(j < v.size() && v[j].first <= vi[i]) {
			w += v[j++].second;
		}
		//cout << i << ' ' << vi[i] << ' ' << w << '\n';
		ans = min(ans,w+max(i,1)-1);
	}
	cout << ans << '\n';
	return 0;
}


#include<bits/stdc++.h>
#include<stdint.h>
using namespace std;
#define IOS {cin.tie(0);ios_base::sync_with_stdio(false);}
#define N 105000

int vi[N];
vector<pair<int,int> > v;

int main(){
	IOS;
	int n,m,l,r,y;
	cin >> n >> m;
	for(int i=0;i<n;i++) cin >> vi[i];
	vi[n] = 1e9;
	sort(vi,vi+n);
	for(int i=0;i<m;i++){
		cin >> l >> r >> y;
		v.push_back({l,1});
		v.push_back({r+1,-1});
	}
	sort(v.begin(),v.end());
	int ans = N*100,j = 0,w = 0;
	for(int i=0;i<=n;i++){
		while(j < v.size() && v[j].first <= vi[i]) {
			w += v[j++].second;
		}
		//cout << i << ' ' << vi[i] << ' ' << w << '\n';
		ans = min(ans,w+i);
	}
	cout << ans << '\n';
	return 0;
}


#include<bits/stdc++.h>
#include<stdint.h>
using namespace std;
#define IOS {cin.tie(0);ios_base::sync_with_stdio(false);}
#define N 105000

int vi[N];
vector<pair<int,int> > v;

int main(){
	IOS;
	int n,m,l,r,y;
	cin >> n >> m;
	for(int i=0;i<n;i++) cin >> vi[i];
	vi[n] = 1e9;
	sort(vi,vi+n);
	int w = 0;
	for(int i=0;i<m;i++){
		cin >> l >> r >> y;
		if(l==1) w++,v.push_back({r+1,-1});
	}
	sort(v.begin(),v.end());
	int ans = w,j = 0;
	for(int i=0;i<=n;i++){
		while(j < v.size() && v[j].first <= vi[i]) {
			w += v[j++].second;
		}
		//cout << i << ' ' << vi[i] << ' ' << w << '\n';
		ans = min(ans,w+i);
	}
	cout << ans << '\n';
	return 0;
}


#include<bits/stdc++.h>
#include<stdint.h>
using namespace std;
#define IOS {cin.tie(0);ios_base::sync_with_stdio(false);}
#define N 105000

int vi[N];
vector<pair<int,int> > v;

int main(){
	IOS;
	int n,m,l,r,y;
	cin >> n >> m;
	for(int i=1;i<=n;i++) cin >> vi[i];
	vi[n+1] = 1e9;
	n+=1;
	sort(vi+1,vi+n+1);
	for(int i=0;i<m;i++){
		cin >> l >> r >> y;
		v.push_back({l,1});
		v.push_back({r+1,-1});
	}
	sort(v.begin(),v.end());
	int ans = N*100,j = 0,w = 0;
	for(int i=1;i<=n;i++){
		while(j < v.size() && v[j].first <= vi[i]) {
			w += v[j++].second;
		}
		//cout << i << ' ' << vi[i] << ' ' << w << '\n';
		ans = min(ans,w+i-1);
	}
	cout << ans << '\n';
	return 0;
}


#include<bits/stdc++.h>
#include<stdint.h>
using namespace std;
#define IOS {cin.tie(0);ios_base::sync_with_stdio(false);}
#define N 105000

int vi[N];
vector<pair<int,int> > v;

int main(){
	IOS;
	int n,m,l,r,y;
	cin >> n >> m;
	for(int i=0;i<n;i++) cin >> vi[i];
	sort(vi,vi+n);
	for(int i=0;i<m;i++){
		cin >> l >> r >> y;
		if(l > 1) v.push_back({l-1,0});
		v.push_back({l,1});
		if(r < 1e9-1)v.push_back({r+1,-1});
	}
	sort(v.begin(),v.end());
	int now = 0,j = 0,ans = N*100;
	//for(int i=0;i<v.size();i++) cout << v[i].first << ' ' << v[i].second << '\n';
	for(int i=0;i<v.size();i++){
		now += v[i].second;
		while(i+1<v.size() && v[i+1].first == v[i].first) now += v[++i].second;
		while(j < n && vi[j] < v[i].first) j++;
		ans = min(ans,j+now);
		//cout << i  << ' ' << v[i].first << ' ' << j << ' ' << now << '\n';
	}
	if(ans == N*100) ans = 0;
	cout << ans << '\n';
	return 0;
}


#include<bits/stdc++.h>
#include<stdint.h>
using namespace std;
#define IOS {cin.tie(0);ios_base::sync_with_stdio(false);}
#define N 105000

int vi[N];
vector<pair<int,int> > v;

int main(){
	IOS;
	int n,m,l,r,y;
	cin >> n >> m;
	for(int i=0;i<n;i++) cin >> vi[i];
	sort(vi,vi+n);
	for(int i=0;i<m;i++){
		cin >> l >> r >> y;
		v.push_back({l,1});
		if(r < 1e9)v.push_back({r+1,-1});
	}
	v.push_back({1,0});
	sort(v.begin(),v.end());
	int now = 0,j = 0,ans = N*100;
	//for(int i=0;i<v.size();i++) cout << v[i].first << ' ' << v[i].second << '\n';
	for(int i=0;i<v.size();i++){
		now += v[i].second;
		while(i+1<v.size() && v[i+1].first == v[i].first) now += v[++i].second;
		while(j < n && vi[j] < v[i].first) j++;
		ans = min(ans,j+now);
		//cout << i << ' ' << j << ' ' << now << '\n';
	}
	cout << ans << '\n';
	return 0;
}


#include<bits/stdc++.h>
#include<stdint.h>
using namespace std;
#define IOS {cin.tie(0);ios_base::sync_with_stdio(false);}
#define N 105000

int vi[N];
vector<pair<int,int> > v;

int main(){
	IOS;
	int n,m,l,r,y;
	cin >> n >> m;
	for(int i=1;i<=n;i++) cin >> vi[i];
	vi[0] = 1;
	vi[n+1] = 1e9;
	sort(vi+1,vi+n+1);
	for(int i=0;i<m;i++){
		cin >> l >> r >> y;
		v.push_back({l,1});
		v.push_back({r+1,-1});
	}
	sort(v.begin(),v.end());
	int ans = N*100,j = 0,w = 0;
	for(int i=0;i<=n+1;i++){
		while(j < v.size() && v[j].first <= vi[i]) {
			w += v[j++].second;
		}
		//cout << i << ' ' << vi[i] << ' ' << w << '\n';
		ans = min(ans,w+max(i,1)-1);
	}
	cout << ans << '\n';
	return 0;
}


#pragma region Template
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <stdio.h>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <ctgmath>
#include <iomanip>
#pragma comment(linker, "/STACK:200000000")
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef pair<int, double> pid;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const double pi = 3.141592653589793238462643383279502884;
const double eps = 1e-6;

#define ff first
#define ss second

#pragma endregion

int main()
{
	cin.sync_with_stdio(false);
	int n, m;
	vector<int> vert;
	vector<int> horiz;
	cin >> n >> m;
	for (int i = 0; i < n; ++i)
	{
		int x;
		cin >> x;
		vert.push_back(x);
	}
	for (int i = 0; i < m; ++i)
	{
		int x1, x2, y;
		cin >> x1 >> x2 >> y;
		if (x1 != 1)
			continue;
		horiz.push_back(x2);
	}
	sort(vert.begin(), vert.end());
	sort(horiz.begin(), horiz.end());
	vert.push_back(1e9 + 100);
	int horiz_pos = 0;
	int ans = 1e9 + 100;
	for (int i = 0; i < vert.size(); ++i)
	{
		int y = vert[i];
		while (horiz_pos < horiz.size() && y > horiz[horiz_pos])
			horiz_pos++;
		ans = min(ans, i + (int)horiz.size() - horiz_pos);
	}
	cout << ans;
	return 0;
}
/*
*/


#pragma region Template
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <stdio.h>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <ctgmath>
#include <iomanip>
#pragma comment(linker, "/STACK:200000000")
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef pair<int, double> pid;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const double pi = 3.141592653589793238462643383279502884;
const double eps = 1e-6;

#define ff first
#define ss second

#pragma endregion

int main()
{
	cin.sync_with_stdio(false);
	int n, m;
	vector<int> vert;
	vector<int> horiz;
	cin >> n >> m;
	for (int i = 0; i < n; ++i)
	{
		int x;
		cin >> x;
		vert.push_back(x);
	}
	for (int i = 0; i < m; ++i)
	{
		int x1, x2, y;
		cin >> x1 >> x2 >> y;
		if (x1 != 1)
			continue;
		horiz.push_back(x2);
	}
	sort(vert.begin(), vert.end());
	sort(horiz.begin(), horiz.end());
	vert.push_back(1e9);
	int horiz_pos = 0;
	int ans = 1e9 + 100;
	for (int i = 0; i < vert.size(); ++i)
	{
		int y = vert[i];
		while (horiz_pos < horiz.size() && y > horiz[horiz_pos])
			horiz_pos++;
		ans = min(ans, i + (int)horiz.size() - horiz_pos);
	}
	cout << ans;
	return 0;
}
/*
*/


/*  ---------------  Copyrighted With  -----------------

   -----   ----   -------   |      |   ------   ------     -----    -----  |     /
  |         |     |     |   |      |  |         |     |   |        |       |   /
  |         |     |------   |------|   -----    |-----     -----   |         /\
  |         |     |         |      |  |         |  \      |        |       |   \
   -----   ----   |         |      |   ------   |    \     ------   ----   |     \

*/

#include<bits/stdc++.h>
using namespace std;

/* ----------------------------- START of Template ---------------*/

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop") // to pop argument of function as soon as it returns
#define ll long long
#define pb push_back
#define fs first
#define se second
// error checking
#define whatIs(x) cout<<#x<<" is "<<x<<endl
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
//
#define rd(x) scanf("%lld", &x)
#define all(v) v.begin(),v.end()
#define pr(i, j) pair< i , j >
#define mp(i, j) map< i , j >
#define rep(i, a, b) for(ll i=a; i<b; ++i)
#define repe(i, a, b) for(ll i=a; i<=b; ++i)
#define jrep(i, a, b, c) for(ll i=a; i<b; i+=c)
#define jrepe(i, a, b, c) for(ll i=a;i<=b; i+=c)
#define inp(i, n, a) for(ll i=0;i<n;i++) cin>>a[i];
#define repall(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
ll dx[4]={-1, 0, 0, +1};
ll dy[4]={0, -1, +1, 0};
const ll LINF = 1e18;
const ll INF = 1e9;
const ll MOD = 1e9+7;

ll strtoll(string s) { stringstream str(s); ll number=0; str>>number; return number; }

string lltostr(ll n){ stringstream ss; ss<<n; return ss.str(); }

ll llsqrt(ll x){ if(x==0 || x==1) return x; ll start=1, end=x/2, ans; while(start<=end) { ll mid=(start+end)/2; if(mid*mid==x) return mid;
        else if(mid <= x/mid) ans=mid,start=mid+1; else end=mid-1; }  return ans; }

vector<ll> spf;
void sieve(ll size) { spf.resize(size+1); for(ll i=1;i<=size; ++i) spf[i]=i; for(ll i=4;i<=size; i+=2) spf[i]=2;
    for(ll i=3;i*i<=size; ++i) { if(spf[i]==i) { for(ll j=i*i; j<=size; j+=i) if(spf[j]==j) spf[j]=i; } } }

ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m); t=(t*t)%m; if(b&1)t=(t*a)%m; return t;}

ll modInverse(ll a, ll m) { return power(a, m-2, m); }

void fastscan(ll &number){ bool negative = false; register ll c; number = 0; c = getchar(); if (c=='-') { negative = true; c = getchar(); }
    for (; (c>47 && c<58); c=getchar()) number = number *10 + c - 48; if (negative)  number *= -1;   }

/* ----------------------          End Of Template --------------------------------*/

ll solve()
{
    ll n,m;
    cin>>n>>m;
    vector<ll> v(n);
    inp(i, n, v);
    v.pb(0);
    v.pb(1e9);
    sort(all(v));

    map<ll, set<pair<ll,ll> > > h;
    for(ll i=0;i<m;i++)
    {
        ll x1,x2,y;
        cin>>x1>>x2>>y;
        h[y].insert({x1, x2});
    }

    vector<ll> s;

    for(auto it : h)
    {
        auto it1=*((it.se).begin());
        if(it1.fs>1)
            s.pb(1);
        else
            s.pb(it1.se + 1);
    }
    sort(all(s));
    ll ans=1e9;
    // for(auto it : s) cout<<it<<" ";
    // cout<<endl;
    for(ll i=0;i<v.size();i++)
    {
        ll idx=upper_bound(s.begin(), s.end(), v[i+1])-s.begin();
        ans=min(ans, i+(ll)s.size()-idx);
    }
    cout<<ans<<endl;
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
   // clock_t tStart = clock();

  /*---------------------------------------------------------------------------------------------------*/

    ll t;
    t=1;
    for(ll i=1;i<=t;i++)
    {
        solve();
    }

  /*---------------------------------------------------------------------------------------------------*/

   // printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    return 0;
}


/*  ---------------  Copyrighted With  -----------------

   -----   ----   -------   |      |   ------   ------     -----    -----  |     /
  |         |     |     |   |      |  |         |     |   |        |       |   /
  |         |     |------   |------|   -----    |-----     -----   |         /\
  |         |     |         |      |  |         |  \      |        |       |   \
   -----   ----   |         |      |   ------   |    \     ------   ----   |     \

*/

#include<bits/stdc++.h>
using namespace std;

/* ----------------------------- START of Template ---------------*/

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop") // to pop argument of function as soon as it returns
#define ll long long
#define pb push_back
#define fs first
#define se second
// error checking
#define whatIs(x) cout<<#x<<" is "<<x<<endl
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
//
#define rd(x) scanf("%lld", &x)
#define all(v) v.begin(),v.end()
#define pr(i, j) pair< i , j >
#define mp(i, j) map< i , j >
#define rep(i, a, b) for(ll i=a; i<b; ++i)
#define repe(i, a, b) for(ll i=a; i<=b; ++i)
#define jrep(i, a, b, c) for(ll i=a; i<b; i+=c)
#define jrepe(i, a, b, c) for(ll i=a;i<=b; i+=c)
#define inp(i, n, a) for(ll i=0;i<n;i++) cin>>a[i];
#define repall(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
ll dx[4]={-1, 0, 0, +1};
ll dy[4]={0, -1, +1, 0};
const ll LINF = 1e18;
const ll INF = 1e9;
const ll MOD = 1e9+7;

ll strtoll(string s) { stringstream str(s); ll number=0; str>>number; return number; }

string lltostr(ll n){ stringstream ss; ss<<n; return ss.str(); }

ll llsqrt(ll x){ if(x==0 || x==1) return x; ll start=1, end=x/2, ans; while(start<=end) { ll mid=(start+end)/2; if(mid*mid==x) return mid;
        else if(mid <= x/mid) ans=mid,start=mid+1; else end=mid-1; }  return ans; }

vector<ll> spf;
void sieve(ll size) { spf.resize(size+1); for(ll i=1;i<=size; ++i) spf[i]=i; for(ll i=4;i<=size; i+=2) spf[i]=2;
    for(ll i=3;i*i<=size; ++i) { if(spf[i]==i) { for(ll j=i*i; j<=size; j+=i) if(spf[j]==j) spf[j]=i; } } }

ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m); t=(t*t)%m; if(b&1)t=(t*a)%m; return t;}

ll modInverse(ll a, ll m) { return power(a, m-2, m); }

void fastscan(ll &number){ bool negative = false; register ll c; number = 0; c = getchar(); if (c=='-') { negative = true; c = getchar(); }
    for (; (c>47 && c<58); c=getchar()) number = number *10 + c - 48; if (negative)  number *= -1;   }

/* ----------------------          End Of Template --------------------------------*/

ll solve()
{
    ll n,m;
    cin>>n>>m;
    vector<ll> v(n);
    inp(i, n, v);
    v.pb(0);
    v.pb(1e9);
    sort(all(v));

    map<ll, set<pair<ll,ll> > > h;
    for(ll i=0;i<m;i++)
    {
        ll x1,x2,y;
        cin>>x1>>x2>>y;
        h[y].insert({x1, x2});
    }

    vector<ll> s;

    for(auto it : h)
    {
        auto it1=*((it.se).begin());
        if(it1.fs>1)
            s.pb(1);
        else
            s.pb(it1.se + 1);
    }
    sort(all(s));
    ll ans=1e9;
    // for(auto it : s) cout<<it<<" ";
    // cout<<endl;
    for(ll i=0;i+1<v.size();i++)
    {
        ll idx=upper_bound(s.begin(), s.end(), v[i+1])-s.begin();
        ans=min(ans, i+(ll)s.size()-idx);
    }
    cout<<ans<<endl;
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
   // clock_t tStart = clock();

  /*---------------------------------------------------------------------------------------------------*/

    ll t;
    t=1;
    for(ll i=1;i<=t;i++)
    {
        solve();
    }

  /*---------------------------------------------------------------------------------------------------*/

   // printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    return 0;
}


#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "../benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7; //998244353

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	int n,m;
	cin>>n>>m;
	vector<int> vs(n);
	rep(i,n) cin>>vs[i];
	vector<int> hs{-1};
	rep(i,m){
		int l,r,y;
		cin>>l>>r>>y;
		if(l==1) hs.pb(r);
	}
	sort(rall(vs));
	sort(all(hs));
	int rem=0;
	const int N=1000000000;
	while(hs.back()==N) hs.pop_back(), ++rem;
	int vc=n;
	int re=rem+vc;
	for(int x:vs){
		--vc;
		while(hs.back()>=x) hs.pop_back(), ++rem;
		MN(re,rem+vc);
	}
	cout<<re<<endl;
  return 0;
}


/*
ID: dorijan1
TASK: tu napisi ime zadatka molim te molim te ali samo ako si na usaco training
LANG: C++11
*/
#include <bits/stdc++.h>
#define x first
#define y second
#define pii pair<int,int>
#define rand rund

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
const int MOD=1000000007;
const int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w)
{
	cout<<w.size()<<endl;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	cout<<w[w.size()-1]<<endl;
}

ll raand()
{
	ll a=rand();
	a*=RAND_MAX;
	a+=rand();
    return a;
}

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll gcd(ll a,ll b)
{
	if (b==0) return a;
	return gcd(b,a%b);
}

ll lcm(ll a,ll b)
{
	return a/gcd(a,b)*b;
}

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

ll mult(ll a,ll b)
{
	return (a*b)%MOD;
}

ll pot(ll n,ll k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

ll divide(ll a,ll b)
{
	return mult(a,pot(b,MOD-2));
}

ll sub(ll a,ll b)
{
	return (a-b+MOD)%MOD;
}

ll add(ll a,ll b)
{
	return (a+b)%MOD;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

pair<int,int> has(string x)
{
	ll h1=0,h2=0;
	x=to_lower(x);
	for (char a: x)
	{
		h1*=bases[0];
		h1+=a-'a';
		h1%=MOD;
		h2*=bases[1];
		h2+=a-'a';
		h2%=MOD2;
	}
	return make_pair(h1,h2);
}

const int N=300010;
int n;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(raand()+13893829);
	cin>>n;
}


/*
ID: dorijan1
TASK: tu napisi ime zadatka molim te molim te ali samo ako si na usaco training
LANG: C++11
*/
#include <bits/stdc++.h>
#define x first
#define y second
#define pii pair<int,int>
#define rand rund

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
const int MOD=1000000007;
const int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w)
{
	cout<<w.size()<<endl;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	cout<<w[w.size()-1]<<endl;
}

ll raand()
{
	ll a=rand();
	a*=RAND_MAX;
	a+=rand();
    return a;
}

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll gcd(ll a,ll b)
{
	if (b==0) return a;
	return gcd(b,a%b);
}

ll lcm(ll a,ll b)
{
	return a/gcd(a,b)*b;
}

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

ll mult(ll a,ll b)
{
	return (a*b)%MOD;
}

ll pot(ll n,ll k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

ll divide(ll a,ll b)
{
	return mult(a,pot(b,MOD-2));
}

ll sub(ll a,ll b)
{
	return (a-b+MOD)%MOD;
}

ll add(ll a,ll b)
{
	return (a+b)%MOD;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

pair<int,int> has(string x)
{
	ll h1=0,h2=0;
	x=to_lower(x);
	for (char a: x)
	{
		h1*=bases[0];
		h1+=a-'a';
		h1%=MOD;
		h2*=bases[1];
		h2+=a-'a';
		h2%=MOD2;
	}
	return make_pair(h1,h2);
}

const int N=300010;
int n,m,pr,r;
map<int,int> ma;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(raand()+13893829);
	cin>>n>>m;
	for (int i=0;i<n;++i)
	{
		int a;
		cin>>a;
		++ma[a+1];
	}
	for (int i=0;i<m;++i)
	{
		int a,b,c;
		cin>>a>>b>>c;
		++ma[a];
		--ma[b+1];
	}
	ma[1e9]=0;
	r=pr=ma[1];
	for (auto x: ma)
	{
		if (x.first>1e9) continue;
		if (x.first==1) continue;
		pr+=x.second;
		r=min(r,pr);
	}
	cout<<r;
}


/*
ID: dorijan1
TASK: tu napisi ime zadatka molim te molim te ali samo ako si na usaco training
LANG: C++11
*/
#include <bits/stdc++.h>
#define x first
#define y second
#define pii pair<int,int>
#define rand rund

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
const int MOD=1000000007;
const int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w)
{
	cout<<w.size()<<endl;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	cout<<w[w.size()-1]<<endl;
}

ll raand()
{
	ll a=rand();
	a*=RAND_MAX;
	a+=rand();
    return a;
}

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll gcd(ll a,ll b)
{
	if (b==0) return a;
	return gcd(b,a%b);
}

ll lcm(ll a,ll b)
{
	return a/gcd(a,b)*b;
}

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

ll mult(ll a,ll b)
{
	return (a*b)%MOD;
}

ll pot(ll n,ll k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

ll divide(ll a,ll b)
{
	return mult(a,pot(b,MOD-2));
}

ll sub(ll a,ll b)
{
	return (a-b+MOD)%MOD;
}

ll add(ll a,ll b)
{
	return (a+b)%MOD;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

pair<int,int> has(string x)
{
	ll h1=0,h2=0;
	x=to_lower(x);
	for (char a: x)
	{
		h1*=bases[0];
		h1+=a-'a';
		h1%=MOD;
		h2*=bases[1];
		h2+=a-'a';
		h2%=MOD2;
	}
	return make_pair(h1,h2);
}

const int N=300010;
int n,m,pr,r;
map<int,int> ma;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(raand()+13893829);
	cin>>n>>m;
	for (int i=0;i<n;++i)
	{
		int a;
		cin>>a;
		++ma[a+1];
	}
	for (int i=0;i<m;++i)
	{
		int a,b,c;
		cin>>a>>b>>c;
		++ma[a];
		--ma[b+1];
	}
	ma[1e9]=0;
	r=MOD;
	for (auto x: ma)
	{
		if (x.first>1e9) continue;
		pr+=x.second;
		r=min(r,pr);
	}
	cout<<r;
}


/*
ID: dorijan1
TASK: tu napisi ime zadatka molim te molim te ali samo ako si na usaco training
LANG: C++11
*/
#include <bits/stdc++.h>
#define x first
#define y second
#define pii pair<int,int>
#define rand rund

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
const int MOD=1000000007;
const int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w)
{
	cout<<w.size()<<endl;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	cout<<w[w.size()-1]<<endl;
}

ll raand()
{
	ll a=rand();
	a*=RAND_MAX;
	a+=rand();
    return a;
}

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll gcd(ll a,ll b)
{
	if (b==0) return a;
	return gcd(b,a%b);
}

ll lcm(ll a,ll b)
{
	return a/gcd(a,b)*b;
}

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

ll mult(ll a,ll b)
{
	return (a*b)%MOD;
}

ll pot(ll n,ll k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

ll divide(ll a,ll b)
{
	return mult(a,pot(b,MOD-2));
}

ll sub(ll a,ll b)
{
	return (a-b+MOD)%MOD;
}

ll add(ll a,ll b)
{
	return (a+b)%MOD;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

pair<int,int> has(string x)
{
	ll h1=0,h2=0;
	x=to_lower(x);
	for (char a: x)
	{
		h1*=bases[0];
		h1+=a-'a';
		h1%=MOD;
		h2*=bases[1];
		h2+=a-'a';
		h2%=MOD2;
	}
	return make_pair(h1,h2);
}

const int N=300010;
int n,m,pr,r=MOD,h[N];
vector<int> e;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(raand()+13893829);
	cin>>n>>m;
	for (int i=0;i<n;++i)
	{
		cin>>h[i];
	}
	sort(h,h+n);
	h[n]=1e9;
	for (int i=0;i<m;++i)
	{
		int a,b,c;
		cin>>a>>b>>c;
		if (a==1) e.push_back(b);
	}
	sort(e.begin(),e.end());
	int a=0;
	for (int i=0;i<=n;++i)
	{
		while (a<e.size() && e[a]<h[i]) ++a;
		r=min(r,(int)e.size()-a+i);
	}
	cout<<r;
}


#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;
#define ll long long
ll p = 998244353;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m;
    cin>>n>>m;
    vector<int> vert(n);
    int temp;
    for (int i = 0; i<n; i++)
    {
        cin>>vert[i];
    }
    sort(vert.begin(), vert.end());
    int counter = 0;
    vector<int> hor;
    for (int i = 0; i<m; i++)
    {
        int x1, x2, y; cin>>x1>>x2>>y;
        if (x1!=1) continue;
        if (x2==1e9) counter++;
        else hor.push_back(x2);
    }
    sort(hor.begin(), hor.end());
    int k = hor.size();
    int ans = 10000000;
    for (int i = 0; i<n; i++)
    {
        int lol = lower_bound(hor.begin(), hor.end(), vert[i]) - hor.begin();
        //cout<<k<<' '<<lol<<' '<<i<<' '<<(k-lol+i)<<endl;
        ans = min(ans, (k-lol)+i);
    }
    ans = min(ans, n);
    cout<<counter+ans;
}


#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;
#define ll long long

void print(vector<int> &a)
{
    for (int i = 0; i<a.size(); i++) cout<<a[i]<<' ';
    cout<<endl;
}

const ll p = 1e9 + 7;

int n, m;

vector<int> ver;
vector<int> hor;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

    cin>>n>>m;
    int x1, x2, y;
    int counter = 0;
    for (int i = 0; i<n; i++) {cin>>x1; ver.push_back(x1);}
    for (int i = 0; i<m; i++) {cin>>x1>>x2>>y; if (x1==1&&x2==1000000000) counter++; else if (x1==1) hor.push_back(x2);}
    sort(ver.begin(), ver.end());
    sort(hor.begin(), hor.end());

    /*print(ver);
    print(hor);*/

    int h = hor.size();

    int minn = 1000000;
    for (int i = 0; i<n; i++)
    {
        int it = lower_bound(hor.begin(), hor.end(), ver[i]) - hor.begin();
        minn = min(minn, i + h-it);
    }
    minn = min(minn, n);
    cout<<minn+counter;

}


#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>

using namespace std;

int n, m;

vector<int> a;

vector<int> b;

int main(){
    cin >> n >> m;
    for(int i = 1;i <= n;i++){
        int num;
        scanf("%d", &num);
        a.push_back(num);
    }
    sort(a.begin(), a.end());
    for(int i = 1;i <= m;i++){
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        if(x == 1){
            b.push_back(y);
        }
    }
    sort(b.begin(), b.end());
    int id = lower_bound(b.begin(), b.end(), 1000000000) - b.begin();
    int ans = n + (b.size() - id);
    for(int i = 0;i < n;i++){
        int id = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
        int tmp = i + (b.size() - id);
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

const int DIM = 100010;

int n, m, i, x, y, z, a[DIM], b[DIM], nr, minim = (1 << 30);

int main() {
    cin >> n >> m;
    for (i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (i = 1; i <= m; ++i) {
        cin >> x >> y >> z;
        if (x == 1) {
            b[++nr] = y;
        }
    }
    m = nr;
    sort (a + 1, a + n + 1);
    sort (b + 1, b + m + 1);
    a[++n] = 1e9;
    x = 1;
    for (i = 1; i <= n; ++i) {
        while (x <= m && a[i] > b[x]) {
            ++x;
        }
        y = i + m - x;
        minim = (minim < y ? minim : y);
    }
    cout << minim << "\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define M 998244353
#define mp make_pair
#define eps 1e-12
#define int long long
#define float long double
#pragma GCC optimize("Ofast")
#pragma unroll
#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define _CRT_SECURE_NO_WARNINGS

int a[300010],b[300010],z=0,ans,c[311010],d[300010],mat[1001][1001],x,m,n;long double an[2000],S,D,S1,S2,X,Y,tim,te=0,tt=0,tt1=0;
string st1[1000001],st,st2,st3;char str[1000001],ch1[1000100],ch,ch2,ch3,*si;
 int modulo(int a,int b=M-2,int n=M){
    int x=1,y=a;
    while(b > 0){
        if(b%2 == 1){
            x=(x*y)%n;
        }
        y = (y*y)%n; // squaring the base
        b /= 2;
    }
    return x%n;
}
vector<int> g[300001];
vector<int> h[100001];
struct node{
mutable int v,i,n;
node(){}
node(int x,int y,int z=0)
{
v=x;i=y;n=z;
}
bool operator<(const node&y)const
{
if(v==y.v)
if(i!=y.i)return i<y.i; else return n<y.n;
else
return v<y.v;
}
};
ostream& operator<<(ostream& o,node x)
{
o<<'('<<x.v<<','<<x.i;
if(x.n>0)
o<<','<<x.n;
o<<")\t";
return o;
}
template<class T >
ostream& operator<<(ostream& o,vector<T> v)
{
for(T x : v)o<<x<<' ';
o<<endl;
return o;
}
template<class T ,class T1>
ostream& operator<<(ostream& o,map<T,T1> v)
{
for(auto x : v)o<<x.first<<' '<<x.second<<endl;
o<<endl;
return o;
}
template<class T >
ostream& operator<<(ostream& o,set<T> v)
{
for(T x : v)o<<x<<' ';
o<<endl;
return o;
}
template<class T >
ostream& operator<<(ostream& o,multiset<T> v)
{
for(T x : v)o<<x<<' ';
o<<endl;
return o;
}
template<class T,class T2 >
ostream& operator<<(ostream& o,pair<T,T2> v)
{
o<<v.first<<' '<<v.second<<endl;
return o;
}
template<class T1,class T2>
T2 min(T1 a,T2 b)
{
return min((T2)a,b);
}
template<class T1,class T2>
T2 max(T1 a,T2 b)
{
return max((T2)a,b);
}
bool cmp(node x,node y)
{
if(x.i!=y.i)
return x.i<y.i;
else if(x.v!=y.v) return x.v>y.v;
else return x.n<y.n;
}
int vis[100001]={0};

class UF    {
public:
    int *id, cnt, *sz;

	// Create an empty union find data structure with N isolated sets.
    UF(int N)   {
        cnt = N;
	id = new int[N];
	sz = new int[N];
        for(int i=0; i<N; i++)	{
            id[i] = i;
	    sz[i] = 1;
	}
    }
    ~UF()	{
	delete [] id;
	delete [] sz;
    }
	// Return the id of component corresponding to object p.
    int find(int p)	{
        int root = p;
        while (root != id[root])
            root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
	// Replace sets containing x and y with their union.
    void merge(int x, int y)	{
        int i = find(x);
        int j = find(y);
        if (i == j) return;

		// make smaller root point to larger one
        if   (sz[i] < sz[j])	{
		id[i] = j;
		sz[j] += sz[i];
	} else	{
		id[j] = i;
		sz[i] += sz[j];
	}
        cnt--;
    }
	// Are objects x and y in the same set?
    bool connected(int x, int y)    {
        return find(x) == find(y);
    }
	// Return the number of disjoint sets.
    int count() {
        return cnt;
    }

};
void tree(int i)
{
for(int x:g[i])
g[x].erase(find(g[x].begin(),g[x].end(),i)),tree(x);
}
void factorial(int *b,int* c)
{
b[0]=1;int i;
for(i=1;i<=100005;i++)
b[i]=b[i-1]*i%M;
c[100002]=modulo(b[100002],M-2,M);
for(i=100001;i>-1;i--)
c[i]=c[i+1]*(i+1)%M;
}
int comb(int n,int r,int* b,int* c)
{
if(r>n)return 0;
return b[n]*c[n-r]%M*c[r]%M;
}

long double flor(long double x)
{
if(abs(x-round(x))<1e-12)
return round(x);
else return floor(x);
}
int ceil(int x,int y)
{
return x/y+(x%y!=0);
}
int rond(float x)
{
int y=round(x);
if(x-y>0&&x-y-0.5>-eps)
return y+1;
else return y;
}
bool prime(int n)
{
if(n==1)return 1;
for(int i=2;i*i<=n;i++)
if(n%i==0)return 0;
return 1;
}
set<int> found;
bool exist(int x)
{
for(int i=2;i*i<=x;i++)
if(x%i==0&&(found.find(i)!=found.end()||found.find(x/i)!=found.end()))
return 1;
return 0;
}
int32_t main()
{
    std::ios::sync_with_stdio(false);
cin.tie(NULL);
 int t,j,r,q,u,s1,s2,s3,bb,l,c1,v1,v2,z,c2,n1,nn,x1,hx,hy,tx,ty,n2, js,maxi,i,s,n3,L,R,mx,p,v,o,m1,k1,k,k2,N,T,y,x3,y3,w,sq,x2,y1,y2,p1,
q1;
T=1;
//cin>>T;
//factorial(b,c);
srand(time(NULL));
tim=clock();float ti=0;
N=T;
while(T--)
{
//cout<<"Case #"<<N-T<<": ";
cin>>n>>m;
vector<int> r;
vector<vector<pair<int,int> > > vert;
for(i=0;i<n;i++)
cin>>a[i];
sort(a,a+n);
s=0;s2=0;
for(i=0;i<m;i++)
{
cin>>x1>>x2>>y;
if(x1==1&&x2==1000000000)
{s2++;continue;}
if(x1==1&&n>0&&x2>=a[0])
r.push_back(x2);
}
if(n==0)
{cout<<s2<<endl;return 0;}
//cout<<r;
m=r.size();
s=m;
sort(r.begin(),r.end());
s1=min(s,n);
i=0;j=0;
while(i<n&&j<m)
{
if(r[j]>=a[i])
s++,i++;
else s--,j++;
assert(s>=0);
s1=min(s1,s);
}

cout<<s1+s2<<endl;

}
cerr<<(clock()-tim)/CLOCKS_PER_SEC<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define M 998244353
#define mp make_pair
#define eps 1e-12
#define int long long
#define float long double
#pragma GCC optimize("Ofast")
#pragma unroll
#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define _CRT_SECURE_NO_WARNINGS

int a[300010],b[300010],z=0,ans,c[311010],d[300010],mat[1001][1001],x,m,n;long double an[2000],S,D,S1,S2,X,Y,tim,te=0,tt=0,tt1=0;
string st1[1000001],st,st2,st3;char str[1000001],ch1[1000100],ch,ch2,ch3,*si;
 int modulo(int a,int b=M-2,int n=M){
    int x=1,y=a;
    while(b > 0){
        if(b%2 == 1){
            x=(x*y)%n;
        }
        y = (y*y)%n; // squaring the base
        b /= 2;
    }
    return x%n;
}
vector<int> g[300001];
vector<int> h[100001];
struct node{
mutable int v,i,n;
node(){}
node(int x,int y,int z=0)
{
v=x;i=y;n=z;
}
bool operator<(const node&y)const
{
if(v==y.v)
if(i!=y.i)return i<y.i; else return n<y.n;
else
return v<y.v;
}
};
ostream& operator<<(ostream& o,node x)
{
o<<'('<<x.v<<','<<x.i;
if(x.n>0)
o<<','<<x.n;
o<<")\t";
return o;
}
template<class T >
ostream& operator<<(ostream& o,vector<T> v)
{
for(T x : v)o<<x<<' ';
o<<endl;
return o;
}
template<class T ,class T1>
ostream& operator<<(ostream& o,map<T,T1> v)
{
for(auto x : v)o<<x.first<<' '<<x.second<<endl;
o<<endl;
return o;
}
template<class T >
ostream& operator<<(ostream& o,set<T> v)
{
for(T x : v)o<<x<<' ';
o<<endl;
return o;
}
template<class T >
ostream& operator<<(ostream& o,multiset<T> v)
{
for(T x : v)o<<x<<' ';
o<<endl;
return o;
}
template<class T,class T2 >
ostream& operator<<(ostream& o,pair<T,T2> v)
{
o<<v.first<<' '<<v.second<<endl;
return o;
}
template<class T1,class T2>
T2 min(T1 a,T2 b)
{
return min((T2)a,b);
}
template<class T1,class T2>
T2 max(T1 a,T2 b)
{
return max((T2)a,b);
}
bool cmp(node x,node y)
{
if(x.i!=y.i)
return x.i<y.i;
else if(x.v!=y.v) return x.v>y.v;
else return x.n<y.n;
}
int vis[100001]={0};

class UF    {
public:
    int *id, cnt, *sz;

	// Create an empty union find data structure with N isolated sets.
    UF(int N)   {
        cnt = N;
	id = new int[N];
	sz = new int[N];
        for(int i=0; i<N; i++)	{
            id[i] = i;
	    sz[i] = 1;
	}
    }
    ~UF()	{
	delete [] id;
	delete [] sz;
    }
	// Return the id of component corresponding to object p.
    int find(int p)	{
        int root = p;
        while (root != id[root])
            root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
	// Replace sets containing x and y with their union.
    void merge(int x, int y)	{
        int i = find(x);
        int j = find(y);
        if (i == j) return;

		// make smaller root point to larger one
        if   (sz[i] < sz[j])	{
		id[i] = j;
		sz[j] += sz[i];
	} else	{
		id[j] = i;
		sz[i] += sz[j];
	}
        cnt--;
    }
	// Are objects x and y in the same set?
    bool connected(int x, int y)    {
        return find(x) == find(y);
    }
	// Return the number of disjoint sets.
    int count() {
        return cnt;
    }

};
void tree(int i)
{
for(int x:g[i])
g[x].erase(find(g[x].begin(),g[x].end(),i)),tree(x);
}
void factorial(int *b,int* c)
{
b[0]=1;int i;
for(i=1;i<=100005;i++)
b[i]=b[i-1]*i%M;
c[100002]=modulo(b[100002],M-2,M);
for(i=100001;i>-1;i--)
c[i]=c[i+1]*(i+1)%M;
}
int comb(int n,int r,int* b,int* c)
{
if(r>n)return 0;
return b[n]*c[n-r]%M*c[r]%M;
}

long double flor(long double x)
{
if(abs(x-round(x))<1e-12)
return round(x);
else return floor(x);
}
int ceil(int x,int y)
{
return x/y+(x%y!=0);
}
int rond(float x)
{
int y=round(x);
if(x-y>0&&x-y-0.5>-eps)
return y+1;
else return y;
}
bool prime(int n)
{
if(n==1)return 1;
for(int i=2;i*i<=n;i++)
if(n%i==0)return 0;
return 1;
}
set<int> found;
bool exist(int x)
{
for(int i=2;i*i<=x;i++)
if(x%i==0&&(found.find(i)!=found.end()||found.find(x/i)!=found.end()))
return 1;
return 0;
}
int32_t main()
{
    std::ios::sync_with_stdio(false);
cin.tie(NULL);
 int t,j,r,q,u,s1,s2,s3,bb,l,c1,v1,v2,z,c2,n1,nn,x1,hx,hy,tx,ty,n2, js,maxi,i,s,n3,L,R,mx,p,v,o,m1,k1,k,k2,N,T,y,x3,y3,w,sq,x2,y1,y2,p1,
q1;
T=1;
//cin>>T;
//factorial(b,c);
srand(time(NULL));
tim=clock();float ti=0;
N=T;
while(T--)
{
//cout<<"Case #"<<N-T<<": ";
cin>>n>>m;
vector<int> r;
for(i=0;i<n;i++)
cin>>a[i];
s=0;s2=0;
for(i=0;i<m;i++)
{
cin>>x1>>x2>>y;
if(x1==1&&x2==1e9)
{s2++;continue;}
if(x1==1&&x2>=a[0])
r.push_back(x2);
if(x1==1&&x2>=a[0])
s++;
}
//cout<<r;
m=r.size();
sort(r.begin(),r.end());
s1=min(s,n);
i=0;j=0;
while(i<n&&j<m)
{
if(r[j]>=a[i])
s++,i++;
else s--,j++;
s1=min(s1,s);
}

cout<<s1+s2<<endl;

}
cerr<<(clock()-tim)/CLOCKS_PER_SEC<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define M 998244353
#define mp make_pair
#define eps 1e-12
#define int long long
#define float long double
#pragma GCC optimize("Ofast")
#pragma unroll
#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define _CRT_SECURE_NO_WARNINGS

int a[300010],b[300010],z=0,ans,c[311010],d[300010],mat[1001][1001],x,m,n;long double an[2000],S,D,S1,S2,X,Y,tim,te=0,tt=0,tt1=0;
string st1[1000001],st,st2,st3;char str[1000001],ch1[1000100],ch,ch2,ch3,*si;
 int modulo(int a,int b=M-2,int n=M){
    int x=1,y=a;
    while(b > 0){
        if(b%2 == 1){
            x=(x*y)%n;
        }
        y = (y*y)%n; // squaring the base
        b /= 2;
    }
    return x%n;
}
vector<int> g[300001];
vector<int> h[100001];
struct node{
mutable int v,i,n;
node(){}
node(int x,int y,int z=0)
{
v=x;i=y;n=z;
}
bool operator<(const node&y)const
{
if(v==y.v)
if(i!=y.i)return i<y.i; else return n<y.n;
else
return v<y.v;
}
};
ostream& operator<<(ostream& o,node x)
{
o<<'('<<x.v<<','<<x.i;
if(x.n>0)
o<<','<<x.n;
o<<")\t";
return o;
}
template<class T >
ostream& operator<<(ostream& o,vector<T> v)
{
for(T x : v)o<<x<<' ';
o<<endl;
return o;
}
template<class T ,class T1>
ostream& operator<<(ostream& o,map<T,T1> v)
{
for(auto x : v)o<<x.first<<' '<<x.second<<endl;
o<<endl;
return o;
}
template<class T >
ostream& operator<<(ostream& o,set<T> v)
{
for(T x : v)o<<x<<' ';
o<<endl;
return o;
}
template<class T >
ostream& operator<<(ostream& o,multiset<T> v)
{
for(T x : v)o<<x<<' ';
o<<endl;
return o;
}
template<class T,class T2 >
ostream& operator<<(ostream& o,pair<T,T2> v)
{
o<<v.first<<' '<<v.second<<endl;
return o;
}
template<class T1,class T2>
T2 min(T1 a,T2 b)
{
return min((T2)a,b);
}
template<class T1,class T2>
T2 max(T1 a,T2 b)
{
return max((T2)a,b);
}
bool cmp(node x,node y)
{
if(x.i!=y.i)
return x.i<y.i;
else if(x.v!=y.v) return x.v>y.v;
else return x.n<y.n;
}
int vis[100001]={0};

class UF    {
public:
    int *id, cnt, *sz;

	// Create an empty union find data structure with N isolated sets.
    UF(int N)   {
        cnt = N;
	id = new int[N];
	sz = new int[N];
        for(int i=0; i<N; i++)	{
            id[i] = i;
	    sz[i] = 1;
	}
    }
    ~UF()	{
	delete [] id;
	delete [] sz;
    }
	// Return the id of component corresponding to object p.
    int find(int p)	{
        int root = p;
        while (root != id[root])
            root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
	// Replace sets containing x and y with their union.
    void merge(int x, int y)	{
        int i = find(x);
        int j = find(y);
        if (i == j) return;

		// make smaller root point to larger one
        if   (sz[i] < sz[j])	{
		id[i] = j;
		sz[j] += sz[i];
	} else	{
		id[j] = i;
		sz[i] += sz[j];
	}
        cnt--;
    }
	// Are objects x and y in the same set?
    bool connected(int x, int y)    {
        return find(x) == find(y);
    }
	// Return the number of disjoint sets.
    int count() {
        return cnt;
    }

};
void tree(int i)
{
for(int x:g[i])
g[x].erase(find(g[x].begin(),g[x].end(),i)),tree(x);
}
void factorial(int *b,int* c)
{
b[0]=1;int i;
for(i=1;i<=100005;i++)
b[i]=b[i-1]*i%M;
c[100002]=modulo(b[100002],M-2,M);
for(i=100001;i>-1;i--)
c[i]=c[i+1]*(i+1)%M;
}
int comb(int n,int r,int* b,int* c)
{
if(r>n)return 0;
return b[n]*c[n-r]%M*c[r]%M;
}

long double flor(long double x)
{
if(abs(x-round(x))<1e-12)
return round(x);
else return floor(x);
}
int ceil(int x,int y)
{
return x/y+(x%y!=0);
}
int rond(float x)
{
int y=round(x);
if(x-y>0&&x-y-0.5>-eps)
return y+1;
else return y;
}
bool prime(int n)
{
if(n==1)return 1;
for(int i=2;i*i<=n;i++)
if(n%i==0)return 0;
return 1;
}
set<int> found;
bool exist(int x)
{
for(int i=2;i*i<=x;i++)
if(x%i==0&&(found.find(i)!=found.end()||found.find(x/i)!=found.end()))
return 1;
return 0;
}
int32_t main()
{
    std::ios::sync_with_stdio(false);
cin.tie(NULL);
 int t,j,r,q,u,s1,s2,s3,bb,l,c1,v1,v2,z,c2,n1,nn,x1,hx,hy,tx,ty,n2, js,maxi,i,s,n3,L,R,mx,p,v,o,m1,k1,k,k2,N,T,y,x3,y3,w,sq,x2,y1,y2,p1,
q1;
T=1;
//cin>>T;
//factorial(b,c);
srand(time(NULL));
tim=clock();float ti=0;
N=T;
while(T--)
{
//cout<<"Case #"<<N-T<<": ";
cin>>n>>m;
vector<int> r;
vector<vector<pair<int,int> > > vert;
for(i=0;i<n;i++)
cin>>a[i];
s=0;s2=0;
for(i=0;i<m;i++)
{
cin>>x1>>x2>>y;
if(x1==1&&x2==1000000000)
{s2++;continue;}
if(x1==1&&n>0&&x2>=a[0])
r.push_back(x2);
}
if(n==0)
{cout<<s2<<endl;return 0;}
//cout<<r;
m=r.size();
s=m;
sort(r.begin(),r.end());
s1=min(s,n);
i=0;j=0;
while(i<n&&j<m)
{
if(r[j]>=a[i])
s++,i++;
else s--,j++;
assert(s>=0);
s1=min(s1,s);
}

cout<<s1+s2<<endl;

}
cerr<<(clock()-tim)/CLOCKS_PER_SEC<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define M 998244353
#define mp make_pair
#define eps 1e-12
#define int long long
#define float long double
#pragma GCC optimize("Ofast")
#pragma unroll
#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define _CRT_SECURE_NO_WARNINGS

int a[300010],b[300010],z=0,ans,c[311010],d[300010],mat[1001][1001],x,m,n;long double an[2000],S,D,S1,S2,X,Y,tim,te=0,tt=0,tt1=0;
string st1[1000001],st,st2,st3;char str[1000001],ch1[1000100],ch,ch2,ch3,*si;
 int modulo(int a,int b=M-2,int n=M){
    int x=1,y=a;
    while(b > 0){
        if(b%2 == 1){
            x=(x*y)%n;
        }
        y = (y*y)%n; // squaring the base
        b /= 2;
    }
    return x%n;
}
vector<int> g[300001];
vector<int> h[100001];
struct node{
mutable int v,i,n;
node(){}
node(int x,int y,int z=0)
{
v=x;i=y;n=z;
}
bool operator<(const node&y)const
{
if(v==y.v)
if(i!=y.i)return i<y.i; else return n<y.n;
else
return v<y.v;
}
};
ostream& operator<<(ostream& o,node x)
{
o<<'('<<x.v<<','<<x.i;
if(x.n>0)
o<<','<<x.n;
o<<")\t";
return o;
}
template<class T >
ostream& operator<<(ostream& o,vector<T> v)
{
for(T x : v)o<<x<<' ';
o<<endl;
return o;
}
template<class T ,class T1>
ostream& operator<<(ostream& o,map<T,T1> v)
{
for(auto x : v)o<<x.first<<' '<<x.second<<endl;
o<<endl;
return o;
}
template<class T >
ostream& operator<<(ostream& o,set<T> v)
{
for(T x : v)o<<x<<' ';
o<<endl;
return o;
}
template<class T >
ostream& operator<<(ostream& o,multiset<T> v)
{
for(T x : v)o<<x<<' ';
o<<endl;
return o;
}
template<class T,class T2 >
ostream& operator<<(ostream& o,pair<T,T2> v)
{
o<<v.first<<' '<<v.second<<endl;
return o;
}
template<class T1,class T2>
T2 min(T1 a,T2 b)
{
return min((T2)a,b);
}
template<class T1,class T2>
T2 max(T1 a,T2 b)
{
return max((T2)a,b);
}
bool cmp(node x,node y)
{
if(x.i!=y.i)
return x.i<y.i;
else if(x.v!=y.v) return x.v>y.v;
else return x.n<y.n;
}
int vis[100001]={0};

class UF    {
public:
    int *id, cnt, *sz;

	// Create an empty union find data structure with N isolated sets.
    UF(int N)   {
        cnt = N;
	id = new int[N];
	sz = new int[N];
        for(int i=0; i<N; i++)	{
            id[i] = i;
	    sz[i] = 1;
	}
    }
    ~UF()	{
	delete [] id;
	delete [] sz;
    }
	// Return the id of component corresponding to object p.
    int find(int p)	{
        int root = p;
        while (root != id[root])
            root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
	// Replace sets containing x and y with their union.
    void merge(int x, int y)	{
        int i = find(x);
        int j = find(y);
        if (i == j) return;

		// make smaller root point to larger one
        if   (sz[i] < sz[j])	{
		id[i] = j;
		sz[j] += sz[i];
	} else	{
		id[j] = i;
		sz[i] += sz[j];
	}
        cnt--;
    }
	// Are objects x and y in the same set?
    bool connected(int x, int y)    {
        return find(x) == find(y);
    }
	// Return the number of disjoint sets.
    int count() {
        return cnt;
    }

};
void tree(int i)
{
for(int x:g[i])
g[x].erase(find(g[x].begin(),g[x].end(),i)),tree(x);
}
void factorial(int *b,int* c)
{
b[0]=1;int i;
for(i=1;i<=100005;i++)
b[i]=b[i-1]*i%M;
c[100002]=modulo(b[100002],M-2,M);
for(i=100001;i>-1;i--)
c[i]=c[i+1]*(i+1)%M;
}
int comb(int n,int r,int* b,int* c)
{
if(r>n)return 0;
return b[n]*c[n-r]%M*c[r]%M;
}

long double flor(long double x)
{
if(abs(x-round(x))<1e-12)
return round(x);
else return floor(x);
}
int ceil(int x,int y)
{
return x/y+(x%y!=0);
}
int rond(float x)
{
int y=round(x);
if(x-y>0&&x-y-0.5>-eps)
return y+1;
else return y;
}
bool prime(int n)
{
if(n==1)return 1;
for(int i=2;i*i<=n;i++)
if(n%i==0)return 0;
return 1;
}
set<int> found;
bool exist(int x)
{
for(int i=2;i*i<=x;i++)
if(x%i==0&&(found.find(i)!=found.end()||found.find(x/i)!=found.end()))
return 1;
return 0;
}
int32_t main()
{
    std::ios::sync_with_stdio(false);
cin.tie(NULL);
 int t,j,r,q,u,s1,s2,s3,bb,l,c1,v1,v2,z,c2,n1,nn,x1,hx,hy,tx,ty,n2, js,maxi,i,s,n3,L,R,mx,p,v,o,m1,k1,k,k2,N,T,y,x3,y3,w,sq,x2,y1,y2,p1,
q1;
T=1;
//cin>>T;
//factorial(b,c);
srand(time(NULL));
tim=clock();float ti=0;
N=T;
while(T--)
{
//cout<<"Case #"<<N-T<<": ";
cin>>n>>m;
vector<int> r;
vector<vector<pair<int,int> > > vert;
for(i=0;i<n;i++)
cin>>a[i];
s=0;s2=0;
for(i=0;i<m;i++)
{
cin>>x1>>x2>>y;
if(x1==1&&x2==1000000000)
{s2++;continue;}
if(x1==1&&n>0&&x2>=a[0])
r.push_back(x2);
}
//cout<<r;
m=r.size();
s=m;
sort(r.begin(),r.end());
s1=min(s,n);
i=0;j=0;
while(i<n&&j<m)
{
if(r[j]>=a[i])
s++,i++;
else s--,j++;
s1=min(s1,s);
}

cout<<s1+s2<<endl;

}
cerr<<(clock()-tim)/CLOCKS_PER_SEC<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define M 998244353
#define mp make_pair
#define eps 1e-12
#define int long long
#define float long double
#pragma GCC optimize("Ofast")
#pragma unroll
#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define _CRT_SECURE_NO_WARNINGS

int a[300010],b[300010],z=0,ans,c[311010],d[300010],mat[1001][1001],x,m,n;long double an[2000],S,D,S1,S2,X,Y,tim,te=0,tt=0,tt1=0;
string st1[1000001],st,st2,st3;char str[1000001],ch1[1000100],ch,ch2,ch3,*si;
 int modulo(int a,int b=M-2,int n=M){
    int x=1,y=a;
    while(b > 0){
        if(b%2 == 1){
            x=(x*y)%n;
        }
        y = (y*y)%n; // squaring the base
        b /= 2;
    }
    return x%n;
}
vector<int> g[300001];
vector<int> h[100001];
struct node{
mutable int v,i,n;
node(){}
node(int x,int y,int z=0)
{
v=x;i=y;n=z;
}
bool operator<(const node&y)const
{
if(v==y.v)
if(i!=y.i)return i<y.i; else return n<y.n;
else
return v<y.v;
}
};
ostream& operator<<(ostream& o,node x)
{
o<<'('<<x.v<<','<<x.i;
if(x.n>0)
o<<','<<x.n;
o<<")\t";
return o;
}
template<class T >
ostream& operator<<(ostream& o,vector<T> v)
{
for(T x : v)o<<x<<' ';
o<<endl;
return o;
}
template<class T ,class T1>
ostream& operator<<(ostream& o,map<T,T1> v)
{
for(auto x : v)o<<x.first<<' '<<x.second<<endl;
o<<endl;
return o;
}
template<class T >
ostream& operator<<(ostream& o,set<T> v)
{
for(T x : v)o<<x<<' ';
o<<endl;
return o;
}
template<class T >
ostream& operator<<(ostream& o,multiset<T> v)
{
for(T x : v)o<<x<<' ';
o<<endl;
return o;
}
template<class T,class T2 >
ostream& operator<<(ostream& o,pair<T,T2> v)
{
o<<v.first<<' '<<v.second<<endl;
return o;
}
template<class T1,class T2>
T2 min(T1 a,T2 b)
{
return min((T2)a,b);
}
template<class T1,class T2>
T2 max(T1 a,T2 b)
{
return max((T2)a,b);
}
bool cmp(node x,node y)
{
if(x.i!=y.i)
return x.i<y.i;
else if(x.v!=y.v) return x.v>y.v;
else return x.n<y.n;
}
int vis[100001]={0};

class UF    {
public:
    int *id, cnt, *sz;

	// Create an empty union find data structure with N isolated sets.
    UF(int N)   {
        cnt = N;
	id = new int[N];
	sz = new int[N];
        for(int i=0; i<N; i++)	{
            id[i] = i;
	    sz[i] = 1;
	}
    }
    ~UF()	{
	delete [] id;
	delete [] sz;
    }
	// Return the id of component corresponding to object p.
    int find(int p)	{
        int root = p;
        while (root != id[root])
            root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
	// Replace sets containing x and y with their union.
    void merge(int x, int y)	{
        int i = find(x);
        int j = find(y);
        if (i == j) return;

		// make smaller root point to larger one
        if   (sz[i] < sz[j])	{
		id[i] = j;
		sz[j] += sz[i];
	} else	{
		id[j] = i;
		sz[i] += sz[j];
	}
        cnt--;
    }
	// Are objects x and y in the same set?
    bool connected(int x, int y)    {
        return find(x) == find(y);
    }
	// Return the number of disjoint sets.
    int count() {
        return cnt;
    }

};
void tree(int i)
{
for(int x:g[i])
g[x].erase(find(g[x].begin(),g[x].end(),i)),tree(x);
}
void factorial(int *b,int* c)
{
b[0]=1;int i;
for(i=1;i<=100005;i++)
b[i]=b[i-1]*i%M;
c[100002]=modulo(b[100002],M-2,M);
for(i=100001;i>-1;i--)
c[i]=c[i+1]*(i+1)%M;
}
int comb(int n,int r,int* b,int* c)
{
if(r>n)return 0;
return b[n]*c[n-r]%M*c[r]%M;
}

long double flor(long double x)
{
if(abs(x-round(x))<1e-12)
return round(x);
else return floor(x);
}
int ceil(int x,int y)
{
return x/y+(x%y!=0);
}
int rond(float x)
{
int y=round(x);
if(x-y>0&&x-y-0.5>-eps)
return y+1;
else return y;
}
bool prime(int n)
{
if(n==1)return 1;
for(int i=2;i*i<=n;i++)
if(n%i==0)return 0;
return 1;
}
set<int> found;
bool exist(int x)
{
for(int i=2;i*i<=x;i++)
if(x%i==0&&(found.find(i)!=found.end()||found.find(x/i)!=found.end()))
return 1;
return 0;
}
int32_t main()
{
    std::ios::sync_with_stdio(false);
cin.tie(NULL);
 int t,j,r,q,u,s1,s2,s3,bb,l,c1,v1,v2,z,c2,n1,nn,x1,hx,hy,tx,ty,n2, js,maxi,i,s,n3,L,R,mx,p,v,o,m1,k1,k,k2,N,T,y,x3,y3,w,sq,x2,y1,y2,p1,
q1;
T=1;
//cin>>T;
//factorial(b,c);
srand(time(NULL));
tim=clock();float ti=0;
N=T;
while(T--)
{
//cout<<"Case #"<<N-T<<": ";
cin>>n>>m;
vector<int> r;
vector<vector<pair<int,int> > > vert;
for(i=0;i<n;i++)
cin>>a[i];
s=0;s2=0;
for(i=0;i<m;i++)
{
cin>>x1>>x2>>y;
if(x1==1&&x2==1000000000)
{s2++;continue;}
if(x1==1&&x2>=a[0])
r.push_back(x2);
}
//cout<<r;
m=r.size();
s=m;
sort(r.begin(),r.end());
s1=min(s,n);
i=0;j=0;
while(i<n&&j<m)
{
if(r[j]>=a[i])
s++,i++;
else s--,j++;
s1=min(s1,s);
}

cout<<s1+s2<<endl;

}
cerr<<(clock()-tim)/CLOCKS_PER_SEC<<endl;
}


#include <iostream>
#include <algorithm>

using namespace std;

const long long INF = 1e9, MAX_N = 1e5 + 7;
long long vert[MAX_N], gor[MAX_N];

int main() {
	//freopen("/Users/ivanvolkov/Desktop/inp.in", "r", stdin);
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	int n, m = 0, mm, ans = 0;
	long long x1, x2, y;
	cin >> n >> mm;
	ans = n;
	for (int i = 0; i < n; i++) cin >> vert[i];
	for (int i = 0; i < mm; i++) {
		cin >> x1 >> x2 >> y;
		if (x1 == 1) {
			gor[m] = x2;
			m++;
			if (x2 == INF) ans++;
		}
	}
	sort(gor, gor + m);
	int l = -1;
	for (int i = 0; i < n; i++) {
		while (l + 1 < m && gor[l + 1] < vert[i]) l++;
		ans = min(ans, i + m - l - 1);
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

const long long INF = 1e9, MAX_N = 1e5 + 7;
long long vert[MAX_N], gor[MAX_N];

int main() {
	//freopen("/Users/ivanvolkov/Desktop/inp.in", "r", stdin);
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	int n, m = 0, mm, ans = 0;
	long long x1, x2, y;
	cin >> n >> mm;
	ans = n;
	for (int i = 0; i < n; i++) cin >> vert[i];
	for (int i = 0; i < mm; i++) {
		cin >> x1 >> x2 >> y;
		if (x1 == 1) {
			gor[m] = x2;
			m++;
			if (x2 == INF) ans++;
		}
	}
	sort(vert, vert + n);
	sort(gor, gor + m);
	int l = -1;
	for (int i = 0; i < n; i++) {
		while (l + 1 < m && gor[l + 1] < vert[i]) l++;
		ans = min(ans, i + m - l - 1);
	}
	cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long int lld;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define trav(a,v) for(auto a:v)

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin>>n>>m;
  int ver[n];
  rep(i,0,n)cin>>ver[i];
  int hor[m][3];
  vector<int> V;
  rep(i,0,m){
    rep(j,0,3)cin>>hor[i][j];
    V.push_back(hor[i][2]);
  }
  sort(V.begin(),V.end());
  V.resize(unique(V.begin(),V.end())-V.begin());
  vector<pair<int,int> > I[V.size()];
  rep(i,0,m){
    int lo=-1;
    int hi=V.size();
    while(hi-lo>1){
      int mid=(hi+lo)/2;
      if(V[mid]<hor[i][2]){
	lo=mid;
      }else hi=mid;
    }
    I[hi].push_back(pair<int,int>(hor[i][0],hor[i][1]));
  }
  vector<pair<int,int> >Q;
  rep(i,0,V.size()){
    sort(I[i].begin(),I[i].end());
    if(I[i][0].first==1){
      if(I[i][0].second!=1000000000)Q.push_back(pair<int,int>(I[i][0].second+1,-1));
    }else{
      Q.push_back(pair<int,int>(1,-1));
    }
  }
  rep(i,0,n)Q.push_back(pair<int,int>(ver[i],1));
  sort(Q.begin(),Q.end());
  //rep(i,0,Q.size())cout<<Q[i].first<<" "<<Q[i].second<<endl;
  lld ans=V.size();
  lld cur=V.size();
  trav(a,Q){
    cur+=a.second;
    ans=min(ans,cur);
  }
  cout<<ans<<endl;
  return 0;
}


#pragma GCC optimize("O3")
#ifdef ONLINE_JUDGE
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif
#pragma GCC optimize("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#include <deque>
#include <type_traits>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
template<typename Key=int,typename Mapped=__gnu_pbds::null_type,typename Cmp_Fn=std::less<Key>,typename Tag=__gnu_pbds::rb_tree_tag,template<typename Const_Node_Iterator,typename Node_Iterator,typename Cmp_Fn_,typename Allocator_>class Node_Update=__gnu_pbds::tree_order_statistics_node_update,typename Allocator=std::allocator<char>>class ordered_set_t:__gnu_pbds::tree<Key,Mapped,Cmp_Fn,Tag,Node_Update,Allocator>{};const int GRANDOM=std::chrono::high_resolution_clock::now().time_since_epoch().count();struct ghash{int operator()(int x){return std::hash<int>{}(x^GRANDOM);}};template<typename KeyType>class hash_table_t:__gnu_pbds::gp_hash_table<KeyType,int,ghash>{};namespace vh{template<class T>void _R(T&x){std::cin>>x;}inline void _R(int&x){scanf("%d",&x);}inline void _R(int64_t&x){scanf("%" SCNd64,&x);}inline void _R(double&x){scanf("%lf",&x);}inline void _R(char&x){scanf(" %c",&x);}inline void _R(char*x){scanf("%s",x);}inline void R(){}template<class T,class... U>inline void R(T&head,U&... tail){_R(head);R(tail...);}template<class T>void _W(const T&x){cout<<x;}inline void _W(const int&x){printf("%d",x);}inline void _W(const int64_t&x){printf("%" PRId64,x);}inline void _W(const double&x){printf("%.16f",x);}inline void _W(const char&x){putchar(x);}inline void _W(const char*x){printf("%s",x);}template<class T>inline void _W(const vector<T>&x){for(auto i=x.begin();i!=x.end();_W(*i++))if(i!=x.cbegin())putchar(' ');}inline void W(){}template<class T,class... U>inline void W(const T&head,const U&... tail){_W(head);if(sizeof...(tail))putchar(' '),W(tail...);}template<class T,class... U>inline void WL(const T&head,const U&... tail){_W(head);putchar(sizeof...(tail)? ' ':'\n');W(tail...);}};
#define prec setprecision
namespace vh{typedef long long ll;typedef unsigned long long llu;template<typename T>T gcd(T m,T n){while(n){T t=m%n;m=n;n=t;};return m;}template<typename T>T exgcd(T a,T b,T&sa,T&ta){T q,r,sb=0,tb=1,sc,tc;sa=1,ta=0;if(b)do q=a/b,r=a-q*b,a=b,b=r,sc=sa-q*sb,sa=sb,sb=sc,tc=ta-q*tb,ta=tb,tb=tc;while(b);return a;}template<typename T>T mul_inv(T a,T b){T t1=a,t2=b,t3;T v1=1,v2=0,v3;T x;while(t2!=1)x=t1/t2,t3=t1-x*t2,v3=v1-x*v2,t1=t2,t2=t3,v1=v2,v2=v3;return(v2+b)%b;}template<typename T>T powmod(T a,T b,T MOD){if(b<0)return 0;T rv=1;while(b)(b%2)&&(rv=(rv*a)%MOD),a=a*a%MOD,b/=2;return rv;}template<typename T>inline T isqrt(T k){T r=sqrt((double)k)+1;while(r*r>k)r--;return r;}template<typename T>inline T icbrt(T k){T r=cbrt((double)k)+1;while(r*r*r>k)r--;return r;}template<typename T>bool mul_overflow(T&r,T a,T b){return __builtin_mul_overflow(a,b,&r);}template<ll n>struct BitSize{enum{Size=BitSize<n/2>::Size+1};};template<>struct BitSize<0>{enum{Size=1};};template<>struct BitSize<1>{enum{Size=1};};
#define BITSIZE(n) (BitSize<n>::Size)
#define BITMAX(n) (BitSize<n>::Size - 1)
#define DEBUG !defined(ONLINE_JUDGE)
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RALL(x) (x).rbegin(),(x).rend()
template<typename TH>void _dbg(const char*sdbg,TH h){cerr<<sdbg<<"="<<h<<"\n";}template<typename TH,typename... TA>void _dbg(const char*sdbg,TH h,TA... t){while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<",";_dbg(sdbg+1,t...);}
#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; for(auto itt: x) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define cerr if(0)cout
#endif
}namespace vh{template<typename T>int min_rotation(vector<T>s){int a=0,N=s.size();for(int b=0;b<N;b++)for(int i=0;i<N;i++){if(a+i==b||s[(a+i)%N]<s[(b+i)%N]){b+=max(0,i-1);break;}if(s[(a+i)%N]>s[(b+i)%N]){a=b;break;}}return a;}}namespace vh{template<typename T,int MAX_LOG>class BIT{public:enum{MAXM=(1<<(1+MAX_LOG))+1,POS_INF=MAXM+1};private:T m[MAXM];inline T acc(T&r,const T&x)const{return r+x;}public:void reset(){memset(m,0,sizeof(m));}inline void update(int x,T v){x+=7;while(x<MAXM)m[x]=acc(m[x],v),x+=x&-x;}T operator()(int x){x+=7;T r=0;while(x>0)r=acc(r,m[x]),x-=x&-x;return r;}T operator[](int x){return(*this)(x)-(*this)(x-1);}};}
namespace vh{
  const int maxcnt=1e5+7;
  int n,m;
  int sx[maxcnt];
  int main(){
    srand(GRANDOM);
    cin>>n>>m;
    for(int i=0;i<n;i++)cin>>sx[i];
    sx[n++]=1e9;
    sort(sx,sx+n);
    vector<int>tx;
    for(int i=0;i<m;i++){
      int x1,x2,y;
      cin>>x1>>x2>>y;
      if(x1==1){
        tx.push_back(x2);
      }
    }
    sort(tx.begin(),tx.end());
    reverse(tx.begin(),tx.end());
    int r=n+m;
    int ti=0;
    for(int i=n-1;i>=0;i--){
      while(ti<SZ(tx)&&tx[ti]>=sx[i])ti++;
      r=min(r,i+ti);
    }
    cout<<r<<endl;
    return 0;
  }
};
int main(int argc,char*argv[]){
  std::cin.sync_with_stdio(false);std::cin.tie(nullptr);
  return vh::main();
}


#pragma GCC optimize("O3")
#ifdef ONLINE_JUDGE
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif
#pragma GCC optimize("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#include <deque>
#include <type_traits>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
template<typename Key=int,typename Mapped=__gnu_pbds::null_type,typename Cmp_Fn=std::less<Key>,typename Tag=__gnu_pbds::rb_tree_tag,template<typename Const_Node_Iterator,typename Node_Iterator,typename Cmp_Fn_,typename Allocator_>class Node_Update=__gnu_pbds::tree_order_statistics_node_update,typename Allocator=std::allocator<char>>class ordered_set_t:__gnu_pbds::tree<Key,Mapped,Cmp_Fn,Tag,Node_Update,Allocator>{};const int GRANDOM=std::chrono::high_resolution_clock::now().time_since_epoch().count();struct ghash{int operator()(int x){return std::hash<int>{}(x^GRANDOM);}};template<typename KeyType>class hash_table_t:__gnu_pbds::gp_hash_table<KeyType,int,ghash>{};namespace vh{template<class T>void _R(T&x){std::cin>>x;}inline void _R(int&x){scanf("%d",&x);}inline void _R(int64_t&x){scanf("%" SCNd64,&x);}inline void _R(double&x){scanf("%lf",&x);}inline void _R(char&x){scanf(" %c",&x);}inline void _R(char*x){scanf("%s",x);}inline void R(){}template<class T,class... U>inline void R(T&head,U&... tail){_R(head);R(tail...);}template<class T>void _W(const T&x){cout<<x;}inline void _W(const int&x){printf("%d",x);}inline void _W(const int64_t&x){printf("%" PRId64,x);}inline void _W(const double&x){printf("%.16f",x);}inline void _W(const char&x){putchar(x);}inline void _W(const char*x){printf("%s",x);}template<class T>inline void _W(const vector<T>&x){for(auto i=x.begin();i!=x.end();_W(*i++))if(i!=x.cbegin())putchar(' ');}inline void W(){}template<class T,class... U>inline void W(const T&head,const U&... tail){_W(head);if(sizeof...(tail))putchar(' '),W(tail...);}template<class T,class... U>inline void WL(const T&head,const U&... tail){_W(head);putchar(sizeof...(tail)? ' ':'\n');W(tail...);}};
#define prec setprecision
namespace vh{typedef long long ll;typedef unsigned long long llu;template<typename T>T gcd(T m,T n){while(n){T t=m%n;m=n;n=t;};return m;}template<typename T>T exgcd(T a,T b,T&sa,T&ta){T q,r,sb=0,tb=1,sc,tc;sa=1,ta=0;if(b)do q=a/b,r=a-q*b,a=b,b=r,sc=sa-q*sb,sa=sb,sb=sc,tc=ta-q*tb,ta=tb,tb=tc;while(b);return a;}template<typename T>T mul_inv(T a,T b){T t1=a,t2=b,t3;T v1=1,v2=0,v3;T x;while(t2!=1)x=t1/t2,t3=t1-x*t2,v3=v1-x*v2,t1=t2,t2=t3,v1=v2,v2=v3;return(v2+b)%b;}template<typename T>T powmod(T a,T b,T MOD){if(b<0)return 0;T rv=1;while(b)(b%2)&&(rv=(rv*a)%MOD),a=a*a%MOD,b/=2;return rv;}template<typename T>inline T isqrt(T k){T r=sqrt((double)k)+1;while(r*r>k)r--;return r;}template<typename T>inline T icbrt(T k){T r=cbrt((double)k)+1;while(r*r*r>k)r--;return r;}template<typename T>bool mul_overflow(T&r,T a,T b){return __builtin_mul_overflow(a,b,&r);}template<ll n>struct BitSize{enum{Size=BitSize<n/2>::Size+1};};template<>struct BitSize<0>{enum{Size=1};};template<>struct BitSize<1>{enum{Size=1};};
#define BITSIZE(n) (BitSize<n>::Size)
#define BITMAX(n) (BitSize<n>::Size - 1)
#define DEBUG !defined(ONLINE_JUDGE)
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RALL(x) (x).rbegin(),(x).rend()
template<typename TH>void _dbg(const char*sdbg,TH h){cerr<<sdbg<<"="<<h<<"\n";}template<typename TH,typename... TA>void _dbg(const char*sdbg,TH h,TA... t){while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<",";_dbg(sdbg+1,t...);}
#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; for(auto itt: x) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define cerr if(0)cout
#endif
}namespace vh{template<typename T>int min_rotation(vector<T>s){int a=0,N=s.size();for(int b=0;b<N;b++)for(int i=0;i<N;i++){if(a+i==b||s[(a+i)%N]<s[(b+i)%N]){b+=max(0,i-1);break;}if(s[(a+i)%N]>s[(b+i)%N]){a=b;break;}}return a;}}namespace vh{template<typename T,int MAX_LOG>class BIT{public:enum{MAXM=(1<<(1+MAX_LOG))+1,POS_INF=MAXM+1};private:T m[MAXM];inline T acc(T&r,const T&x)const{return r+x;}public:void reset(){memset(m,0,sizeof(m));}inline void update(int x,T v){x+=7;while(x<MAXM)m[x]=acc(m[x],v),x+=x&-x;}T operator()(int x){x+=7;T r=0;while(x>0)r=acc(r,m[x]),x-=x&-x;return r;}T operator[](int x){return(*this)(x)-(*this)(x-1);}};}
namespace vh{
  const int maxcnt=1e5+7;
  int n,m;
  int sx[maxcnt];
  vector<tuple<int,int,int>>cuts;
  BIT<ll,18>b;
  int main(){
    srand(GRANDOM);
    b.reset();
    cin>>n>>m;
    sx[0]=0;
    for(int i=1;i<=n;i++)cin>>sx[i];
    sx[n+1]=1e9;
    sort(sx,sx+n+2);
    n=unique(sx,sx+n+2)-sx;
    for(int i=0;i<m;i++){
      int x1,x2,y;
      cin>>x1>>x2>>y;x1--;
      int xid1=lower_bound(sx,sx+n,x1)-sx+1;
      int xid2=upper_bound(sx,sx+n,x2)-sx-1;
      if(xid2>=xid1){
        cuts.push_back({y,xid1,xid2});
      }
    }
    sort(cuts.begin(),cuts.end());
    for(auto [y,x1,x2]:cuts){
      b.update(x1,1);
      b.update(x2+1,-1);
    }
    ll r=m+n;
    for(int i=1,ie=n-1;i<=ie;i++){
      r=min(r,b(i)+i-1);
    }
    cout<<r<<endl;
    return 0;
  }
};
int main(int argc,char*argv[]){
  std::cin.sync_with_stdio(false);std::cin.tie(nullptr);
  return vh::main();
}


#pragma GCC optimize("O3")
#ifdef ONLINE_JUDGE
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif
#pragma GCC optimize("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#include <deque>
#include <type_traits>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
template<typename Key=int,typename Mapped=__gnu_pbds::null_type,typename Cmp_Fn=std::less<Key>,typename Tag=__gnu_pbds::rb_tree_tag,template<typename Const_Node_Iterator,typename Node_Iterator,typename Cmp_Fn_,typename Allocator_>class Node_Update=__gnu_pbds::tree_order_statistics_node_update,typename Allocator=std::allocator<char>>class ordered_set_t:__gnu_pbds::tree<Key,Mapped,Cmp_Fn,Tag,Node_Update,Allocator>{};const int GRANDOM=std::chrono::high_resolution_clock::now().time_since_epoch().count();struct ghash{int operator()(int x){return std::hash<int>{}(x^GRANDOM);}};template<typename KeyType>class hash_table_t:__gnu_pbds::gp_hash_table<KeyType,int,ghash>{};namespace vh{template<class T>void _R(T&x){std::cin>>x;}inline void _R(int&x){scanf("%d",&x);}inline void _R(int64_t&x){scanf("%" SCNd64,&x);}inline void _R(double&x){scanf("%lf",&x);}inline void _R(char&x){scanf(" %c",&x);}inline void _R(char*x){scanf("%s",x);}inline void R(){}template<class T,class... U>inline void R(T&head,U&... tail){_R(head);R(tail...);}template<class T>void _W(const T&x){cout<<x;}inline void _W(const int&x){printf("%d",x);}inline void _W(const int64_t&x){printf("%" PRId64,x);}inline void _W(const double&x){printf("%.16f",x);}inline void _W(const char&x){putchar(x);}inline void _W(const char*x){printf("%s",x);}template<class T>inline void _W(const vector<T>&x){for(auto i=x.begin();i!=x.end();_W(*i++))if(i!=x.cbegin())putchar(' ');}inline void W(){}template<class T,class... U>inline void W(const T&head,const U&... tail){_W(head);if(sizeof...(tail))putchar(' '),W(tail...);}template<class T,class... U>inline void WL(const T&head,const U&... tail){_W(head);putchar(sizeof...(tail)? ' ':'\n');W(tail...);}};
#define prec setprecision
namespace vh{typedef long long ll;typedef unsigned long long llu;template<typename T>T gcd(T m,T n){while(n){T t=m%n;m=n;n=t;};return m;}template<typename T>T exgcd(T a,T b,T&sa,T&ta){T q,r,sb=0,tb=1,sc,tc;sa=1,ta=0;if(b)do q=a/b,r=a-q*b,a=b,b=r,sc=sa-q*sb,sa=sb,sb=sc,tc=ta-q*tb,ta=tb,tb=tc;while(b);return a;}template<typename T>T mul_inv(T a,T b){T t1=a,t2=b,t3;T v1=1,v2=0,v3;T x;while(t2!=1)x=t1/t2,t3=t1-x*t2,v3=v1-x*v2,t1=t2,t2=t3,v1=v2,v2=v3;return(v2+b)%b;}template<typename T>T powmod(T a,T b,T MOD){if(b<0)return 0;T rv=1;while(b)(b%2)&&(rv=(rv*a)%MOD),a=a*a%MOD,b/=2;return rv;}template<typename T>inline T isqrt(T k){T r=sqrt((double)k)+1;while(r*r>k)r--;return r;}template<typename T>inline T icbrt(T k){T r=cbrt((double)k)+1;while(r*r*r>k)r--;return r;}template<typename T>bool mul_overflow(T&r,T a,T b){return __builtin_mul_overflow(a,b,&r);}template<ll n>struct BitSize{enum{Size=BitSize<n/2>::Size+1};};template<>struct BitSize<0>{enum{Size=1};};template<>struct BitSize<1>{enum{Size=1};};
#define BITSIZE(n) (BitSize<n>::Size)
#define BITMAX(n) (BitSize<n>::Size - 1)
#define DEBUG !defined(ONLINE_JUDGE)
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RALL(x) (x).rbegin(),(x).rend()
template<typename TH>void _dbg(const char*sdbg,TH h){cerr<<sdbg<<"="<<h<<"\n";}template<typename TH,typename... TA>void _dbg(const char*sdbg,TH h,TA... t){while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<",";_dbg(sdbg+1,t...);}
#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; for(auto itt: x) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define cerr if(0)cout
#endif
}namespace vh{template<typename T>int min_rotation(vector<T>s){int a=0,N=s.size();for(int b=0;b<N;b++)for(int i=0;i<N;i++){if(a+i==b||s[(a+i)%N]<s[(b+i)%N]){b+=max(0,i-1);break;}if(s[(a+i)%N]>s[(b+i)%N]){a=b;break;}}return a;}}namespace vh{template<typename T,int MAX_LOG>class BIT{public:enum{MAXM=(1<<(1+MAX_LOG))+1,POS_INF=MAXM+1};private:T m[MAXM];inline T acc(T&r,const T&x)const{return r+x;}public:void reset(){memset(m,0,sizeof(m));}inline void update(int x,T v){x+=7;while(x<MAXM)m[x]=acc(m[x],v),x+=x&-x;}T operator()(int x){x+=7;T r=0;while(x>0)r=acc(r,m[x]),x-=x&-x;return r;}T operator[](int x){return(*this)(x)-(*this)(x-1);}};}
namespace vh{
  const int maxcnt=1e5+7;
  int n,m;
  int sx[maxcnt];
  vector<tuple<int,int,int>>cuts;
  BIT<ll,18>b;
  int main(){
    srand(GRANDOM);
    b.reset();
    cin>>n>>m;
    sx[0]=0;
    for(int i=1;i<=n;i++)cin>>sx[i];
    sort(sx+1,sx+n+1);
    sx[n+1]=1e9;
    for(int i=2,ie=n+1;i<=ie;i++){
      b.update(i,1);
    }
    for(int i=0;i<m;i++){
      int x1,x2,y;
      cin>>x1>>x2>>y;x1--;
      int xid1=lower_bound(sx,sx+n+2,x1)-sx+1;
      int xid2=upper_bound(sx,sx+n+2,x2)-sx-1;
      if(xid2>=xid1){
        cuts.push_back({y,xid1,xid2});
      }
    }
    sort(cuts.begin(),cuts.end());
    for(auto [y,x1,x2]:cuts){
      b.update(x1,1);
      b.update(x2+1,-1);
    }
    ll r=m+n;
    for(int i=1,ie=n+1;i<=ie;i++){
      r=min(r,b(i));
    }
    cout<<r<<endl;
    return 0;
  }
};
int main(int argc,char*argv[]){
  std::cin.sync_with_stdio(false);std::cin.tie(nullptr);
  return vh::main();
}


 #include<bits/stdc++.h>
using namespace std;
#define ios ios::sync_with_stdio(false);
#define ll long long
const int maxn=1e6+100;
int xxx[maxn],yyy[maxn];
int main()
{
    ios;
    int n,sx,sy;
    cin>>n>>sx>>sy;
    for(int i=0;i<n;i++){
        cin>>xxx[i]>>yyy[i];
    }
    int pre=0,nex=maxn,up=maxn,down=0;
    for(int i=0;i<n;i++){
        if(xxx[i]<sx){
            pre=max(pre,xxx[i]);
        }
        else if(xxx[i]>sx){
            nex=min(nex,xxx[i]);
        }
        if(yyy[i]>sy){
            up=min(up,yyy[i]);
        }
        else if(yyy[i]<sy){
            down=max(down,yyy[i]);
        }
    }
    int shang=0,xia=0,zuo=0,you=0;
    for(int i=0;i<n;i++){
        if(xxx[i]<=pre){
            zuo++;
        }
        else if(xxx[i]>=nex){
            you++;
        }
        if(yyy[i]>=up){
            shang++;
        }
        else if(yyy[i]<=down){
            xia++;
        }
    }
    if(nex==maxn)nex=-1;
    if(up==maxn)up=-1;
    int ans=max(shang,max(xia,max(zuo,you)));
    cout<<ans<<endl;
    if(ans==shang){
        cout<<sx<<" "<<up<<endl;
    }
    else if(ans==you){
        cout<<nex<<" "<<sy<<endl;
    }
    else if(ans==zuo){
        cout<<pre<<" "<<sy<<endl;
    }
    else if(ans==xia){
        cout<<sx<<" "<<down<<endl;
    }
    return 0;
}
/*
1
0 0
1 0

2 1 1
0 0 2 2
*/


 #include<bits/stdc++.h>
using namespace std;
#define ios ios::sync_with_stdio(false);
#define ll long long
const int maxn=1e6+100;
int xxx[maxn],yyy[maxn];
int main()
{
    ios;
    int n,sx,sy;
    cin>>n>>sx>>sy;
    for(int i=0;i<n;i++){
        cin>>xxx[i]>>yyy[i];
    }
    int pre=0,nex=maxn,up=maxn,down=0;
    for(int i=0;i<n;i++){
        if(xxx[i]<sx){
            pre=max(pre,xxx[i]);
        }
        else if(xxx[i]>sx){
            nex=min(nex,xxx[i]);
        }
        if(yyy[i]>sy){
            up=min(up,yyy[i]);
        }
        else if(yyy[i]<sy){
            down=max(down,yyy[i]);
        }
    }
    int shang=0,xia=0,zuo=0,you=0;
    for(int i=0;i<n;i++){
        if(xxx[i]<=pre){
            zuo++;
        }
        else if(xxx[i]>=nex){
            you++;
        }
        if(yyy[i]>=up){
            shang++;
        }
        else if(yyy[i]<=down){
            xia++;
        }
    }
    if(nex==maxn)nex=-1;
    if(up=maxn)up=-1;
    int ans=max(shang,max(xia,max(zuo,you)));
    cout<<ans<<endl;
    if(ans==shang){
        cout<<sx<<" "<<up<<endl;
    }
    else if(ans==you){
        cout<<nex<<" "<<sy<<endl;
    }
    else if(ans==zuo){
        cout<<pre<<" "<<sy<<endl;
    }
    else if(ans==xia){
        cout<<sx<<" "<<down<<endl;
    }
    return 0;
}
/*
1
0 0
1 0
*/


 #include<bits/stdc++.h>
using namespace std;
#define ios ios::sync_with_stdio(false);
#define ll long long
const int maxn=1e6+100;
int xxx[maxn],yyy[maxn];
int main()
{
    ios;
    int n,sx,sy;
    cin>>n>>sx>>sy;
    for(int i=0;i<n;i++){
        cin>>xxx[i]>>yyy[i];
    }
    int pre=0,nex=maxn,up=maxn,down=0;
    for(int i=0;i<n;i++){
        if(xxx[i]<sx){
            pre=max(pre,xxx[i]);
        }
        else if(xxx[i]>sx){
            nex=min(nex,xxx[i]);
        }
        if(yyy[i]>sy){
            up=min(up,yyy[i]);
        }
        else if(yyy[i]<sy){
            down=max(down,yyy[i]);
        }
    }
    int shang=0,xia=0,zuo=0,you=0;
    for(int i=0;i<n;i++){
        if(xxx[i]<=pre){
            zuo++;
        }
        else if(xxx[i]>=nex){
            you++;
        }
        if(yyy[i]>=up){
            shang++;
        }
        else if(yyy[i]<=down){
            xia++;
        }
    }
    int ans=max(shang,max(xia,max(zuo,you)));
    cout<<ans<<endl;
    if(ans==shang){
        cout<<"0 "<<up<<endl;
    }
    else if(ans==xia){
        cout<<"0 "<<down<<endl;
    }
    else if(ans==zuo){
        cout<<pre<<" 0"<<endl;
    }
    else{
        cout<<nex<<" 0"<<endl;
    }
    return 0;
}