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

bool mysort(pair<ll,pair<ll,ll> > a, pair<ll,pair<ll,ll> > b){
	a.second.first=-a.second.first;
	b.second.first=-b.second.first;

	a.second.second=-a.second.second;
	b.second.second=-b.second.second;

	return a<b;
}

bool works(ll n,ll m,ll k,ll t, ll s[], vector<pair<ll,pair<ll,ll> > > traps, ll sc){
	ll minsold;
	if(sc>0){
		minsold=s[sc-1];
	}
	else{
		minsold=INT_MAX;
	}

	ll trapspointer=0;
	ll currtime=0;
	ll longestgone=0;

	for(int i=0;i<=n;i++){
		longestgone=max(longestgone,(ll)i);
		// cout<<i<<" "<<minsold<<" "<<currtime<<endl;
		while(trapspointer<k && traps[trapspointer].first==i+1){
			if(longestgone<traps[trapspointer].second.first && minsold<traps[trapspointer].second.second){
				currtime+=(traps[trapspointer].second.first-longestgone)*2;
				longestgone=max(longestgone,traps[trapspointer].second.first);
			}
			trapspointer++;
		}
		currtime++;
		if(currtime>t){
			return false;
		}
	}
	return true;
}

int main(){

	#ifndef ONLINE_JUDGE
    	freopen("input", "r", stdin);
    	freopen("output", "w", stdout);
    	freopen("error", "w", stderr);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // binsearch the number of soldiers, act greedy for a soldier count

    ll n,m,k,t;
    cin>>n>>m>>k>>t;

    ll s[n];
    for(int i=0;i<n;i++){
    	cin>>s[i];
    }
    sort(s,s+n);
    reverse(s,s+n);

    vector<pair<ll,pair<ll,ll> > > traps;
    for(int i=0;i<k;i++){
    	pair<ll,pair<ll,ll> > asdf;
    	cin>>asdf.first>>asdf.second.first>>asdf.second.second;
    	traps.push_back(asdf);
    }

    sort(traps.begin(),traps.end());

    ll bmin=0;
    ll bmax=n;
    while(bmin<bmax){
    	ll bmid=ceil(((double)bmax+bmin)/2.0);
    	// cout<<bmin<<" "<<bmax<<" "<<bmid<<endl;
    	if(works(n,m,k,t,s,traps,bmid)){
    		bmin=bmid;
    	}
    	else{
    		bmax=bmid-1;
    	}
    }
    // cout<<bmin<<" "<<bmax<<endl;

    cout<<bmax<<endl;

}


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

int main(){

	#ifndef ONLINE_JUDGE
    	freopen("input", "r", stdin);
    	freopen("output", "w", stdout);
    	freopen("error", "w", stderr);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n,m,k,t;
    cin>>n>>m>>k>>t;

    ll s[m];
    for(int i=0;i<m;i++){
    	sort(s,s+m);
    }

    ll traps[k][3];
    for(int i=0;i<k;i++){
    	cin>>traps[i][0]>>traps[i][1]>>traps[i][2];
    }

    //
    ll nt=t;
    t-=n;//to bring squad
    t/=2;//going and coming back

    ll maxtrap=0;
    for(int i=0;i<k;i++){
    	if(traps[i][1]>t){
    		maxtrap=max(maxtrap,traps[i][2]);
    	}
    }

    ll sc=0;
    for(int i=0;i<m;i++){
    	if(s[i]>=maxtrap)sc++;
    }

    cout<<sc<<endl;
}


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

int main(){

	#ifndef ONLINE_JUDGE
    	freopen("input", "r", stdin);
    	freopen("output", "w", stdout);
    	freopen("error", "w", stderr);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n,m,k,t;
    cin>>n>>m>>k>>t;

    ll s[n];
    for(int i=0;i<n;i++){
    	cin>>s[i];
    }
    sort(s,s+n);

    ll traps[k][3];
    for(int i=0;i<k;i++){
    	cin>>traps[i][0]>>traps[i][1]>>traps[i][2];
    }

    //
    ll nt=t;
    t-=m;//to bring squad
    t/=2;//going and coming back
    // cout<<t<<endl;

    ll maxtrap=0;
    for(int i=0;i<k;i++){
    	if(traps[i][1]>t){
    		maxtrap=max(maxtrap,traps[i][2]);
    	}
    }
    // cout<<maxtrap<<endl;

    ll sc=0;
    for(int i=0;i<n;i++){
    	if(s[i]>=maxtrap)sc++;
    }

    cout<<sc<<endl;
}


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

bool works(ll n,ll m,ll k,ll t, ll s[], vector<pair<ll,pair<ll,ll> > > traps, ll sc){
	ll minsold;
	if(sc>0){
		minsold=s[sc-1];
	}
	else{
		minsold=INT_MAX;
	}

	ll trapspointer=0;
	ll currtime=0;
	ll longestgone=0;

	for(int i=0;i<=n;i++){
		while(trapspointer<k && traps[trapspointer].first==i+1){
			if(longestgone<traps[trapspointer].second.first && minsold<traps[trapspointer].second.second){
				longestgone=max(longestgone,traps[trapspointer].second.first);
				currtime+=(traps[trapspointer].second.first-i)*2;
			}
			trapspointer++;
		}
		currtime++;
		longestgone=max(longestgone,(ll)i+1);
		if(currtime>t){
			return false;
		}
	}
	return true;
}

int main(){

	#ifndef ONLINE_JUDGE
    	freopen("input", "r", stdin);
    	freopen("output", "w", stdout);
    	freopen("error", "w", stderr);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // binsearch the number of soldiers, act greedy for a soldier count

    ll n,m,k,t;
    cin>>n>>m>>k>>t;

    ll s[n];
    for(int i=0;i<n;i++){
    	cin>>s[i];
    }
    sort(s,s+n);
    reverse(s,s+n);

    vector<pair<ll,pair<ll,ll> > > traps;
    for(int i=0;i<k;i++){
    	pair<ll,pair<ll,ll> > asdf;
    	cin>>asdf.first>>asdf.second.first>>asdf.second.second;
    	traps.push_back(asdf);
    }

    sort(traps.begin(),traps.end());

    ll bmin=0;
    ll bmax=n;
    while(bmin<bmax){
    	ll bmid=ceil(((double)bmax+bmin)/2.0);
    	if(works(n,m,k,t,s,traps,bmid)){
    		bmin=bmid;
    	}
    	else{
    		bmax=bmid-1;
    	}
    }
    // cout<<bmin<<" "<<bmax<<endl;

    cout<<bmax<<endl;

}


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

bool mysort(pair<ll,pair<ll,ll> > a, pair<ll,pair<ll,ll> > b){
	a.second.first=-a.second.first;
	b.second.first=-b.second.first;

	a.second.second=-a.second.second;
	b.second.second=-b.second.second;

	return a<b;
}

bool works(ll n,ll m,ll k,ll t, ll s[], vector<pair<ll,pair<ll,ll> > > traps, ll sc){
	ll minsold;
	if(sc>0){
		minsold=s[sc-1];
	}
	else{
		minsold=INT_MAX;
	}

	ll trapspointer=0;
	ll currtime=0;
	ll longestgone=0;

	for(int i=0;i<=n;i++){
		longestgone=max(longestgone,(ll)i);
		// cout<<i<<" "<<minsold<<" "<<currtime<<endl;
		while(trapspointer<k && traps[trapspointer].first==i+1){
			if(longestgone<traps[trapspointer].second.first && minsold<traps[trapspointer].second.second){
				currtime+=(traps[trapspointer].second.first-longestgone)*2;
				longestgone=max(longestgone,traps[trapspointer].second.first);
			}
			trapspointer++;
		}
		currtime++;
		if(currtime>t){
			return false;
		}
	}
	return true;
}

int main(){

	#ifndef ONLINE_JUDGE
    	freopen("input", "r", stdin);
    	freopen("output", "w", stdout);
    	freopen("error", "w", stderr);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // binsearch the number of soldiers, act greedy for a soldier count

    ll n,m,k,t;
    cin>>n>>m>>k>>t;

    ll s[n];
    for(int i=0;i<n;i++){
    	cin>>s[i];
    }
    sort(s,s+n);
    reverse(s,s+n);

    vector<pair<ll,pair<ll,ll> > > traps;
    for(int i=0;i<k;i++){
    	pair<ll,pair<ll,ll> > asdf;
    	cin>>asdf.first>>asdf.second.first>>asdf.second.second;
    	traps.push_back(asdf);
    }

    sort(traps.begin(),traps.end(),mysort);

    ll bmin=0;
    ll bmax=n;
    while(bmin<bmax){
    	ll bmid=ceil(((double)bmax+bmin)/2.0);
    	// cout<<bmin<<" "<<bmax<<" "<<bmid<<endl;
    	if(works(n,m,k,t,s,traps,bmid)){
    		bmin=bmid;
    	}
    	else{
    		bmax=bmid-1;
    	}
    }
    // cout<<bmin<<" "<<bmax<<endl;

    cout<<bmax<<endl;

}


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

bool works(ll n,ll m,ll k,ll t, ll s[], vector<pair<ll,pair<ll,ll> > > traps, ll sc){
	ll minsold;
	if(sc>0){
		minsold=s[sc-1];
	}
	else{
		minsold=INT_MAX;
	}

	// cout<<sc<<" "<<minsold<<endl;

	ll trapspointer=0;
	ll currtime=0;
	ll longestgone=0;

	for(int i=0;i<=n;i++){
		//should i move to i+1
		// if(minsold==3){
		// 	cout<<i<<" "<<currtime<<endl;
		// }

		while(traps[trapspointer].first==i+1){
			if(longestgone<traps[trapspointer].second.first && minsold<traps[trapspointer].second.second){
				longestgone=traps[trapspointer].second.first;
				currtime+=(traps[trapspointer].second.first-i)*2;
			}
			trapspointer++;
		}
		currtime++;
		if((i<n && currtime>=t) || (i==n && currtime>t)){
			return false;
		}
	}
	return true;
}

int main(){

	#ifndef ONLINE_JUDGE
    	freopen("input", "r", stdin);
    	freopen("output", "w", stdout);
    	freopen("error", "w", stderr);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // binsearch the number of soldiers, act greedy for a soldier count

    ll n,m,k,t;
    cin>>n>>m>>k>>t;

    ll s[n];
    for(int i=0;i<n;i++){
    	cin>>s[i];
    }
    sort(s,s+n);
    reverse(s,s+n);

    vector<pair<ll,pair<ll,ll> > > traps;
    for(int i=0;i<k;i++){
    	pair<ll,pair<ll,ll> > asdf;
    	cin>>asdf.first>>asdf.second.first>>asdf.second.second;
    	traps.push_back(asdf);
    }

    sort(traps.begin(),traps.end());

    ll bmin=0;
    ll bmax=n;
    while(bmin<bmax){
    	ll bmid=ceil(((double)bmax+bmin)/2.0);
    	// cout<<bmin<<" "<<bmax<<" "<<bmid<<endl;
    	if(works(n,m,k,t,s,traps,bmid)){
    		bmin=bmid;
    	}
    	else{
    		bmax=bmid-1;
    	}
    }

    cout<<bmin<<endl;

}


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

bool mysort(pair<ll,pair<ll,ll> > a, pair<ll,pair<ll,ll> > b){
	a.second.first=-a.second.first;
	b.second.first=-b.second.first;

	a.second.second=-a.second.second;
	b.second.second=-b.second.second;

	return a<b;
}

bool works(ll n,ll m,ll k,ll t, ll s[], vector<pair<ll,pair<ll,ll> > > traps, ll sc){
	ll minsold;
	if(sc>0){
		minsold=s[sc-1];
	}
	else{
		minsold=INT_MAX;
	}

	ll trapspointer=0;
	ll currtime=0;
	ll longestgone=0;

	for(int i=0;i<=n;i++){
		longestgone=max(longestgone,(ll)i);
		while(trapspointer<k && traps[trapspointer].first==i+1){
			if(longestgone<traps[trapspointer].second.first && minsold<traps[trapspointer].second.second){
				longestgone=max(longestgone,traps[trapspointer].second.first);
				currtime+=(traps[trapspointer].second.first-longestgone)*2;
			}
			trapspointer++;
		}
		currtime++;
		if(currtime>t){
			return false;
		}
	}
	return true;
}

int main(){

	#ifndef ONLINE_JUDGE
    	freopen("input", "r", stdin);
    	freopen("output", "w", stdout);
    	freopen("error", "w", stderr);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // binsearch the number of soldiers, act greedy for a soldier count

    ll n,m,k,t;
    cin>>n>>m>>k>>t;

    ll s[n];
    for(int i=0;i<n;i++){
    	cin>>s[i];
    }
    sort(s,s+n);
    reverse(s,s+n);

    vector<pair<ll,pair<ll,ll> > > traps;
    for(int i=0;i<k;i++){
    	pair<ll,pair<ll,ll> > asdf;
    	cin>>asdf.first>>asdf.second.first>>asdf.second.second;
    	traps.push_back(asdf);
    }

    sort(traps.begin(),traps.end(),mysort);

    ll bmin=0;
    ll bmax=n;
    while(bmin<bmax){
    	ll bmid=ceil(((double)bmax+bmin)/2.0);
    	if(works(n,m,k,t,s,traps,bmid)){
    		bmin=bmid;
    	}
    	else{
    		bmax=bmid-1;
    	}
    }
    // cout<<bmin<<" "<<bmax<<endl;

    cout<<bmax<<endl;

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int b[200001];
int m,n,k,t;
int a[200001];
pair<int,pair<int,int> >p[200001];
bool func(int x){
    x=a[x-1]+1;
    //cout<<x<<endl;
    int temp=-1;
    int cnt=0,ans=0;
    for(int i=0;i<=n;i++){
        b[i]=0;
    }
    for(int i=0;i<k;i++){
        if(p[i].second.second>=x){
            //cout<<p[i].first<<endl;
            if(p[i].first>temp){
                for(int j=p[i].first;j<=p[i].second.first;j++){
                    b[j]=1;
                    //cout<<j<<endl;
                }
                temp=p[i].second.first;
            }
            else if(p[i].second.first>temp){
                //cout<<temp<<endl;
                for(int j=temp+1;j<=p[i].second.first;j++){
                    b[j]=1;
                }
                temp=p[i].second.first;
            }
        }
    }
    for(int i=0;i<=n;i++){
        if(b[i]==1){
            cnt=0;
            while(i<=n&&b[i]==1){
                i++;
                cnt++;
            }
            i--;
            //cout<<cnt<<endl;
            ans+=cnt;
        }
    }
    //cout<<ans<<endl;
    return(2*ans+n+1<=t);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>m>>n>>k>>t;
    for(int i=0;i<m;i++){
        cin>>a[i];
    }
    int l,r,d;
    for(int i=0;i<k;i++){
        cin>>l>>r>>d;
        p[i].first=l;
        p[i].second.first=r;
        p[i].second.second=d;
    }
    sort(a,a+m);
    reverse(a,a+m);
    sort(p,p+k);
    int low=1,high=m,mid,ans=0;
    while(low<=high){
        mid=(low+high)/2;
        if(func(mid)){
            low=mid+1;
            ans=mid;
        }
        else{
            high=mid-1;
        }
    }
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mod=1e9+7;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int m,n,k,t;
    cin>>m>>n>>k>>t;
    int a[m];
    for(int i=0;i<m;i++){
        cin>>a[i];
    }
    pair<int,int>p[k];
    int l,r,d;
    for(int i=0;i<k;i++){
        cin>>l>>r>>d;
        p[i].first=d;
        p[i].second=r;
    }
    sort(a,a+m);
    reverse(a,a+m);
    sort(p,p+k);
    int mx[k];
    mx[k-1]=p[k-1].second;
    for(int i=k-2;i>=0;i--){
        mx[i]=max(mx[i+1],p[i].second);
    }
    int q[k];
    for(int i=0;i<k;i++){
        q[i]=p[i].first;
    }
    int cnt=0;
    for(int i=0;i<m;i++){
        int temp=lower_bound(q,q+k,a[i]+1)-q;
        if(temp==k){
            temp=0;
        }
        else{
            temp=mx[temp];
        }
        if(2*temp+(n+1)<=t){
            cnt++;
        }
        else{
            break;
        }
    }
    cout<<cnt<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int b[200001];
int m,n,k,t;
int a[200001];
pair<int,pair<int,int> >p[200001];
bool func(int x){
    x=a[x-1]+1;
    //cout<<x<<endl;
    int temp=-1;
    int cnt=0,ans=0;
    for(int i=0;i<=n;i++){
        b[i]=0;
    }
    for(int i=0;i<k;i++){
        if(p[i].second.second>=x){
            //cout<<p[i].first<<endl;
            if(p[i].first>temp){
                for(int j=p[i].first;j<=p[i].second.first;j++){
                    b[j]=1;
                    //cout<<j<<endl;
                }
                temp=p[i].second.first;
            }
            else{
                //cout<<temp<<endl;
                for(int j=temp+1;j<=p[i].second.first;j++){
                    b[j]=1;
                }
            }
        }
    }
    for(int i=0;i<=n;i++){
        if(b[i]==1){
            cnt=0;
            while(i<=n&&b[i]==1){
                i++;
                cnt++;
            }
            i--;
            //cout<<cnt<<endl;
            ans+=cnt;
        }
    }
    //cout<<ans<<endl;
    return(2*ans+n+1<=t);
}
ll mod=1e9+7;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>m>>n>>k>>t;
    for(int i=0;i<m;i++){
        cin>>a[i];
    }
    int l,r,d;
    for(int i=0;i<k;i++){
        cin>>l>>r>>d;
        p[i].first=l;
        p[i].second.first=r;
        p[i].second.second=d;
    }
    sort(a,a+m);
    reverse(a,a+m);
    sort(p,p+k);
    int low=1,high=m,mid,ans=0;
    while(low<=high){
        mid=(low+high)/2;
        if(func(mid)){
            low=mid+1;
            ans=mid;
        }
        else{
            high=mid-1;
        }
    }
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mod=1e9+7;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int m,n,k,t;
    cin>>m>>n>>k>>t;
    int a[m];
    for(int i=0;i<m;i++){
        cin>>a[i];
    }
    pair<int,pair<int,int> >p[k];
    int l,r,d;
    for(int i=0;i<k;i++){
        cin>>l>>r>>d;
        p[i].first=d;
        p[i].second.first=l;
        p[i].second.second=r;
    }
    sort(a,a+m);
    reverse(a,a+m);
    sort(p,p+k);
    int mx[k],mn[k];
    mx[k-1]=p[k-1].second.second;
    mn[k-1]=p[k-1].second.first;
    for(int i=k-2;i>=0;i--){
        mx[i]=max(mx[i+1],p[i].second.second);
    }
    for(int i=k-2;i>=0;i--){
        mn[i]=min(mn[i+1],p[i].second.first);
    }
    int q[k];
    for(int i=0;i<k;i++){
        q[i]=p[i].first;
    }
    int cnt=0;
    for(int i=0;i<m;i++){
        int temp=lower_bound(q,q+k,a[i]+1)-q;
        if(temp==k){
            temp=0;
        }
        else{
            temp=mx[temp]-mn[temp]+1;
        }
        //cout<<x<<" "<<y<<" "<<q[temp]<<" "<<a[i]<<endl;
        if(2*(temp)+(n+1)<=t){
            cnt++;
        }
        else{
            break;
        }
    }
    cout<<cnt<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mod=1e9+7;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int m,n,k,t;
    cin>>m>>n>>k>>t;
    int a[m];
    for(int i=0;i<m;i++){
        cin>>a[i];
    }
    pair<int,pair<int,int> >p[k];
    int l,r,d;
    for(int i=0;i<k;i++){
        cin>>l>>r>>d;
        p[i].first=d;
        p[i].second.first=l;
        p[i].second.second=r;
    }
    sort(a,a+m);
    reverse(a,a+m);
    sort(p,p+k);
    int mx[k],mn[k];
    mx[k-1]=p[k-1].second.second;
    mn[k-1]=p[k-1].second.first;
    for(int i=k-2;i>=0;i--){
        mx[i]=max(mx[i+1],p[i].second.second);
    }
    for(int i=k-2;i>=0;i--){
        mn[i]=min(mn[i+1],p[i].second.first);
    }
    int q[k];
    for(int i=0;i<k;i++){
        q[i]=p[i].first;
    }
    int cnt=0;
    int x=INT_MIN,y=INT_MAX;
    for(int i=0;i<m;i++){
        int temp=lower_bound(q,q+k,a[i]+1)-q;
        if(temp==k){
            cnt++;
            continue;
        }
        else{
            x=max(x,mx[temp]);
            y=min(y,mn[temp]);
        }
        //cout<<x<<" "<<y<<" "<<q[temp]<<" "<<a[i]<<endl;
        if(2*(x-y+1)+(n+1)<=t){
            cnt++;
        }
        else{
            break;
        }
    }
    cout<<cnt<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mod=1e9+7;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int m,n,k,t;
    cin>>m>>n>>k>>t;
    int a[m];
    for(int i=0;i<m;i++){
        cin>>a[i];
    }
    pair<int,pair<int,int> >p[k];
    int l,r,d;
    for(int i=0;i<k;i++){
        cin>>l>>r>>d;
        p[i].first=d;
        p[i].second.first=l;
        p[i].second.second=r;
    }
    sort(a,a+m);
    reverse(a,a+m);
    sort(p,p+k);
    int mx[k],mn[k];
    mx[k-1]=p[k-1].second.second;
    mn[k-1]=p[k-1].second.first;
    for(int i=k-2;i>=0;i--){
        mx[i]=max(mx[i+1],p[i].second.second);
    }
    for(int i=k-2;i>=0;i--){
        mn[i]=min(mn[i+1],p[i].second.first);
    }
    int q[k];
    for(int i=0;i<k;i++){
        q[i]=p[i].first;
    }
    int cnt=0;
    for(int i=0;i<m;i++){
        int temp=lower_bound(q,q+k,a[i]+1)-q;
        if(temp==k){
            temp=0;
        }
        else{
            temp=mx[x]-mn[y]+1;
        }
        //cout<<x<<" "<<y<<" "<<q[temp]<<" "<<a[i]<<endl;
        if(2*(temp)+(n+1)<=t){
            cnt++;
        }
        else{
            break;
        }
    }
    cout<<cnt<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mod=1e9+7;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int m,n,k,t;
    cin>>m>>n>>k>>t;
    int a[m];
    for(int i=0;i<m;i++){
        cin>>a[i];
    }
    pair<int,pair<int,int> >p[k];
    int l,r,d;
    for(int i=0;i<k;i++){
        cin>>l>>r>>d;
        p[i].first=d;
        p[i].second.first=l;
        p[i].second.second=r;
    }
    sort(a,a+m);
    reverse(a,a+m);
    sort(p,p+k);
    int mx[k],mn[k];
    mx[k-1]=p[k-1].second.second;
    mn[0]=p[0].second.first;
    for(int i=k-2;i>=0;i--){
        mx[i]=max(mx[i+1],p[i].second.second);
    }
    for(int i=1;i<k;i++){
        mn[i]=min(mn[i-1],p[i].second.first);
    }
    int q[k];
    for(int i=0;i<k;i++){
        q[i]=p[i].first;
    }
    int cnt=0;
    int x=INT_MIN,y=INT_MAX;
    for(int i=0;i<m;i++){
        int temp=lower_bound(q,q+k,a[i]+1)-q;
        if(temp==k){
            cnt++;
            continue;
        }
        else{
            x=max(x,mx[temp]);
            y=min(y,mn[temp]);
        }
        if(2*(x-y)+(n+1)<=t){
            cnt++;
        }
        else{
            break;
        }
    }
    cout<<cnt<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int b[200001];
int m,n,k,t;
int a[200001];
pair<int,pair<int,int> >p[200001];
bool func(int x){
    x=a[x-1]+1;
    //cout<<x<<endl;
    int temp=-1;
    int cnt=0,ans=0;
    for(int i=0;i<=n;i++){
        b[i]=0;
    }
    for(int i=0;i<k;i++){
        if(p[i].second.second>=x){
            //cout<<p[i].first<<endl;
            if(p[i].second.first>temp){
                for(int j=p[i].second.first;j<=p[i].first;j++){
                    b[j]=1;
                    //cout<<j<<endl;
                }
                temp=p[i].first;
            }
            else{
                //cout<<temp<<endl;
                for(int j=temp+1;j<=p[i].first;j++){
                    b[j]=1;
                }
            }
        }
    }
    for(int i=0;i<=n;i++){
        if(b[i]==1){
            cnt=0;
            while(i<=n&&b[i]==1){
                i++;
                cnt++;
            }
            i--;
            //cout<<cnt<<endl;
            ans+=cnt;
        }
    }
    //cout<<ans<<endl;
    return(2*ans+n+1<=t);
}
ll mod=1e9+7;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>m>>n>>k>>t;
    for(int i=0;i<m;i++){
        cin>>a[i];
    }
    int l,r,d;
    for(int i=0;i<k;i++){
        cin>>l>>r>>d;
        p[i].first=r;
        p[i].second.first=l;
        p[i].second.second=d;
    }
    sort(a,a+m);
    reverse(a,a+m);
    sort(p,p+k);
    int low=1,high=m,mid,ans=0;
    while(low<=high){
        mid=(low+high)/2;
        if(func(mid)){
            low=mid+1;
            ans=mid;
        }
        else{
            high=mid-1;
        }
    }
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mod=1e9+7;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int m,n,k,t;
    cin>>m>>n>>k>>t;
    int a[m];
    for(int i=0;i<m;i++){
        cin>>a[i];
    }
    pair<int,pair<int,int> >p[k];
    int l,r,d;
    for(int i=0;i<k;i++){
        cin>>l>>r>>d;
        p[i].first=d;
        p[i].second.first=l;
        p[i].second.second=r;
    }
    sort(a,a+m);
    reverse(a,a+m);
    sort(p,p+k);
    int mx[k],mn[k];
    mx[k-1]=p[k-1].second.second;
    mn[k-1]=p[k-1].second.first;
    for(int i=k-2;i>=0;i--){
        mx[i]=max(mx[i+1],p[i].second.second);
    }
    for(int i=1;i<k;i++){
        mn[i]=min(mn[i+1],p[i].second.first);
    }
    int q[k];
    for(int i=0;i<k;i++){
        q[i]=p[i].first;
    }
    int cnt=0;
    int x=INT_MIN,y=INT_MAX;
    for(int i=0;i<m;i++){
        int temp=lower_bound(q,q+k,a[i]+1)-q;
        if(temp==k){
            cnt++;
            continue;
        }
        else{
            x=max(x,mx[temp]);
            y=min(y,mn[temp]);
        }
        //cout<<x<<" "<<y<<" "<<q[temp]<<" "<<a[i]<<endl;
        if(2*(x-y+1)+(n+1)<=t){
            cnt++;
        }
        else{
            break;
        }
    }
    cout<<cnt<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mod=1e9+7;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int m,n,k,t;
    cin>>m>>n>>k>>t;
    int a[m];
    for(int i=0;i<m;i++){
        cin>>a[i];
    }
    pair<int,int>p[k];
    int l,r,d;
    for(int i=0;i<k;i++){
        cin>>l>>r>>d;
        p[i].first=d;
        p[i].second=r;
    }
    sort(a,a+m);
    reverse(a,a+m);
    sort(p,p+k);
    int mx[k];
    mx[k-1]=p[k-1].second;
    for(int i=k-2;i>=0;i--){
        mx[i]=max(mx[i+1],p[i].second);
    }
    int q[k];
    for(int i=0;i<k;i++){
        q[i]=p[i].first;
    }
    int cnt=0;
    for(int i=0;i<m;i++){
        int temp=lower_bound(q,q+k,a[i]+1)-q;
        temp=mx[temp];
        if(2*temp+(n+1)<=t){
            cnt++;
        }
        else{
            break;
        }
    }
    cout<<cnt<<endl;
}


#include<bits/stdc++.h>

using namespace std;

int a[200100];

struct T{
    int l, r ,d;
}trap[200100];

int n, m ,k, t;

bool check(int x){
    int l = n+1 , r = 0;
    for(int i = 1; i <= k; ++i){
        if(trap[i].d > x){
            l = min(trap[i].l, l);
            r = max(trap[i].r, r);
        }
    }
    return (n+1 + 2*(r-l+1)) <= t;
}

int main(){

    scanf("%d%d%d%d", &m, &n, &k, &t);
    int M = 0;
    for(int i = 1; i <= m; ++i){
        scanf("%d", &a[i]);
        M = max(M, a[i]);
    }
    for(int i = 1; i <= k; ++i){
        scanf("%d%d%d", &trap[i].l, &trap[i].r, &trap[i].d);
    }

    int l = 1, r = M;
    int ans = M+1;
    while(l <= r){
        int mid = (l+r)/2;
        if(check(mid)){
            ans = mid;
            r = mid-1;
        }else{
            l = mid+1;
        }
    }
    int cnt = 0;
    for(int i = 1; i <= m; ++i){
        if(ans <= a[i]) cnt++;
    }
    printf("%d\n", cnt);
}


#include<bits/stdc++.h>

using namespace std;

int a[200100];

struct T{
    int l, r ,d;
}trap[200100];

int n, m ,k, t;
int pref[200100];

bool check(int x){
    memset(pref, 0, sizeof(pref));
    for(int i = 1; i <= k; ++i){
        if(trap[i].d > x)
            pref[trap[i].l]++, pref[trap[i].r+1]--;
    }
    int s = 1;
    for(int i = 1; i <= n; ++i){
        pref[i] += pref[i-1];
        s += (pref[i]>0)*2+1;
    }
    return s<=t;
}

int main(){

    scanf("%d%d%d%d", &m, &n, &k, &t);
    int M = 0;
    for(int i = 1; i <= m; ++i){
        scanf("%d", &a[i]);
        M = max(M, a[i]);
    }
    for(int i = 1; i <= k; ++i){
        scanf("%d%d%d", &trap[i].l, &trap[i].r, &trap[i].d);
    }

    int l = 1, r = M;
    int ans = M+1;
    while(l <= r){
        int mid = (l+r)/2;
        if(check(mid)){
            ans = mid;
            r = mid-1;
        }else{
            l = mid+1;
        }
    }
    int cnt = 0;
    for(int i = 1; i <= m; ++i){
        if(ans <= a[i]) cnt++;
    }
    printf("%d\n", cnt);
}


#include<bits/stdc++.h>

using namespace std;

int a[200100];

struct T{
    int l, r ,d;
    bool operator < (T &b){
        if(l == b.l) return r < b.r;
        return l < b.l;
    }
}trap[200100];
int n, m ,k, t;

bool check(int x){
    int l = 0x3f3f3f3f, r = 0;
    for(int i = 0; i <= k; ++i){
        if(trap[i].d > x){
            l = min(trap[i].l, l);
            r = max(trap[i].r, r);
        }
    }
    return (n + 2*(r-l+1)) <= t;
}

int main(){

    scanf("%d%d%d%d", &m, &n, &k, &t);
    for(int i = 1; i <= m; ++i){
        scanf("%d", &a[i]);
    }
    a[m+1] = 0x3f3f3f3f;
    for(int i = 1; i <= k; ++i){
        scanf("%d%d%d", &trap[i].l, &trap[i].r, &trap[i].d);
    }

    sort(a+1, a+m);
    sort(trap+1, trap+1+k);
    int l = 0, r = m;
    int ans = 0;
    while(l <= r){
        int mid = (l+r)/2;
        if(check(a[m-mid+1])){
            ans = mid;
            l = mid+1;
        }else{
            r = mid-1;
        }
    }
    printf("%d\n", ans);
}


#include<bits/stdc++.h>

using namespace std;

int a[200100];

struct T{
    int l, r ,d;
}trap[200100];

int n, m ,k, t;

bool check(int x){
    int l = 0x3f3f3f3f, r = 0;
    for(int i = 0; i <= k; ++i){
        if(trap[i].d > x){
            l = min(trap[i].l, l);
            r = max(trap[i].r, r);
        }
    }
    return (n + 2*(r-l+1)) < t;
}

int main(){

    scanf("%d%d%d%d", &m, &n, &k, &t);
    int M = 0;
    for(int i = 1; i <= m; ++i){
        scanf("%d", &a[i]);
        M = max(M, a[i]);
    }
    for(int i = 1; i <= k; ++i){
        scanf("%d%d%d", &trap[i].l, &trap[i].r, &trap[i].d);
    }
    int l = 0, r = M;
    int ans = 0x3f3f3f3f;
    while(l <= r){
        int mid = (l+r)/2;
        if(check(mid)){
            ans = mid;
            r = mid-1;
        }else{
            l = mid+1;
        }
    }
    int cnt = 0;
    for(int i = 1; i <= m; ++i){
        if(ans <= a[i]) cnt++;
    }
    printf("%d\n", cnt);
}


#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int m,n,k,t;
int s[100005],flg[100005];
struct p{
	int l;
	int r;
	int d;
}trap [100005];
bool cmp(int x,int y){
	return x>y;
}
bool cmp2(p x,p y){
	return x.l<y.l;
}
int search(int l,int r){
	int mid=(l+r)/2;
	if (l+1==r&&flg[mid]) return mid;
	flg[mid]=1;
	int j=1;
	while (s[mid]>=trap[j].d) j++;// 可以直接带人到 j-1的位置
	int max=j+1;
	for (int i=1;i<=k;i++){
		if (s[mid]<trap[i].d)
		{
			max=(max>trap[i].r)?max:trap[i].r;//max表示最远要走到哪里去解除陷阱
		}
	}
	int T=(max-j+1)*2+n+1;		//T表示带mid个士兵所需时间
	if (T<=t) return search(mid,r);
	else return search(l,mid);
}
int main(){
	scanf("%d %d %d %d",&m,&n,&k,&t);
	for (int i=1;i<=m;i++){
		scanf("%d",&s[i]);
	}
	sort(s+1,s+1+m,cmp);
	for (int i=1;i<=k;i++){
		scanf("%d %d %d",&trap[i].l,&trap[i].r,&trap[i].d);
	}
	sort(trap+1,trap+1+k,cmp2);//按陷阱摆放位置排序
	printf("%d\n",search(-1,m+1));
}


#include<bits/stdc++.h>

using namespace std;

int a[200100];

struct T{
    int l, r ,d;
    bool operator < (T &b){
        if(l == b.l) return r < b.r;
        return l < b.l;
    }
}trap[200100];
int n, m ,k, t;

bool check(int x){
    int l = 0x3f3f3f3f, r = 0;
    for(int i = 0; i <= k; ++i){
        if(trap[i].d > x){
            l = min(trap[i].l, l);
            r = max(trap[i].r, r);
        }
    }
    return (n + 2*(r-l+1)) < t;
}

int main(){

    scanf("%d%d%d%d", &m, &n, &k, &t);
    for(int i = 1; i <= m; ++i){
        scanf("%d", &a[i]);
    }
    a[m+1] = 0x3f3f3f3f;
    for(int i = 1; i <= k; ++i){
        scanf("%d%d%d", &trap[i].l, &trap[i].r, &trap[i].d);
    }

    sort(a+1, a+m);
    sort(trap+1, trap+1+k);
    int l = 0, r = m;
    int ans = 0;
    while(l <= r){
        int mid = (l+r)/2;
        if(check(a[m-mid+1])){
            ans = mid;
            l = mid+1;
        }else{
            r = mid-1;
        }
    }
    printf("%d\n", ans);
}


#include<bits/stdc++.h>

using namespace std;

int a[200100];

struct{
    int l, r ,d;
}trap[200100];
int n, m ,k, t;

bool check(int x){
    int l = 0x3f3f3f3f, r = 0;
    for(int i = 0; i <= k; ++i){
        if(trap[i].d > a[m-x+1]){
            l = min(trap[i].l, l);
            r = max(trap[i].r, r);
        }
    }
    return (n + 2*(r-l+1)) <= t;
}

int main(){

    scanf("%d%d%d%d", &m, &n, &k, &t);
    for(int i = 1; i <= m; ++i){
        scanf("%d", &a[i]);
    }
    a[m+1] = 0x3f3f3f3f;
    for(int i = 1; i <= k; ++i){
        int l, r, d;
        scanf("%d%d%d", &trap[i].l, &trap[i].r, &trap[i].d);
    }

    sort(a+1, a+m);
    int l = 0, r = m;
    int ans = 0;
    while(l <= r){
        int mid = (l+r)/2;
        if(check(mid)){
            ans = mid;
            l = mid+1;
        }else{
            r = mid-1;
        }
    }
    printf("%d\n", ans);
}


#include<bits/stdc++.h>

using namespace std;

int a[200100];

struct T{
    int l, r ,d;
}trap[200100];

int n, m ,k, t;

bool check(int x){
    int l = 0x3f3f3f3f, r = 0;
    for(int i = 0; i <= k; ++i){
        if(trap[i].d > x){
            l = min(trap[i].l, l);
            r = max(trap[i].r, r);
        }
    }
    return (n + 2*(r-l+1)) <= t;
}

int main(){

    scanf("%d%d%d%d", &m, &n, &k, &t);
    int M = 0;
    for(int i = 1; i <= m; ++i){
        scanf("%d", &a[i]);
        M = max(M, a[i]);
    }
    for(int i = 1; i <= k; ++i){
        scanf("%d%d%d", &trap[i].l, &trap[i].r, &trap[i].d);
    }
    int l = 0, r = M;
    int ans = 0x3f3f3f3f;
    while(l <= r){
        int mid = (l+r)/2;
        if(check(mid)){
            ans = mid;
            r = mid-1;
        }else{
            l = mid+1;
        }
    }
    int cnt = 0;
    for(int i = 1; i <= m; ++i){
        if(ans <= a[i]) cnt++;
    }
    printf("%d\n", cnt);
}


#include<bits/stdc++.h>

using namespace std;

int a[200100];

struct{
    int l, r ,d;
}trap[200100];
int n, m ,k, t;

bool check(int x){
    int l = 0x3f3f3f3f, r = 0;
    for(int i = 0; i <= k; ++i){
        if(trap[i].d > a[m-x+1]){
            l = min(trap[i].l, l);
            r = max(trap[i].r, r);
        }
    }
    return (n + 2*(r-l+1)) <= t;
}

int main(){

    scanf("%d%d%d%d", &m, &n, &k, &t);
    for(int i = 1; i <= m; ++i){
        scanf("%d", &a[i]);
    }
    for(int i = 1; i <= k; ++i){
        int l, r, d;
        scanf("%d%d%d", &trap[i].l, &trap[i].r, &trap[i].d);
    }

    sort(a+1, a+m);
    int l = 0, r = m;
    while(r-l > 1){
        int mid = (l+r)/2;
        if(check(mid)){
            l = mid;
        }else{
            r = mid;
        }
    }
    printf("%d\n", l);
}


#include<bits/stdc++.h>

using namespace std;

int a[200100];

struct T{
    int l, r ,d;
    bool operator < (T &b){
        if(l == b.l) return r < b.r;
        return l < b.l;
    }
}trap[200100];
int n, m ,k, t;

bool check(int x){
    int l = 0x3f3f3f3f, r = 0;
    for(int i = 0; i <= k; ++i){
        if(trap[i].d > x){
            l = min(trap[i].l, l);
            r = max(trap[i].r, r);
        }
    }
    return (n + 2*(r-l+1)) < t;
}

int main(){

    scanf("%d%d%d%d", &m, &n, &k, &t);
    for(int i = 1; i <= m; ++i){
        scanf("%d", &a[i]);
    }
    for(int i = 1; i <= k; ++i){
        scanf("%d%d%d", &trap[i].l, &trap[i].r, &trap[i].d);
    }

    sort(a+1, a+m);
    sort(trap+1, trap+1+k);
    int l = 0, r = a[m];
    int ans = 0;
    while(l <= r){
        int mid = (l+r)/2;
        if(check(mid)){
            ans = mid;
            r = mid-1;
        }else{
            l = mid+1;
        }
    }
    int cnt = 0;
    for(int i = 1; i <= m; ++i){
        if(ans <= a[i]) cnt++;
    }
    printf("%d\n", cnt);
}


#include<bits/stdc++.h>

using namespace std;

int a[200100];

struct T{
    int l, r ,d;
}trap[200100];

int n, m ,k, t;
int pref[200100];

bool check(int x){
    memset(pref, 0, sizeof(pref));
    for(int i = 1; i <= k; ++i){
        pref[trap[i].l]++, pref[trap[i].r+1]--;
    }
    int s = 1;
    for(int i = 1; i <= n; ++i){
        pref[i] += pref[i-1];
        s += (pref[i]>0)*2+1;
    }
    return s<=t;
}

int main(){

    scanf("%d%d%d%d", &m, &n, &k, &t);
    int M = 0;
    for(int i = 1; i <= m; ++i){
        scanf("%d", &a[i]);
        M = max(M, a[i]);
    }
    for(int i = 1; i <= k; ++i){
        scanf("%d%d%d", &trap[i].l, &trap[i].r, &trap[i].d);
    }

    int l = 1, r = M;
    int ans = M+1;
    while(l <= r){
        int mid = (l+r)/2;
        if(check(mid)){
            ans = mid;
            r = mid-1;
        }else{
            l = mid+1;
        }
    }
    int cnt = 0;
    for(int i = 1; i <= m; ++i){
        if(ans <= a[i]) cnt++;
    }
    printf("%d\n", cnt);
}


#include<bits/stdc++.h>

using namespace std;

int a[200100];

struct{
    int l, r ,d;
}trap[200100];
int n, m ,k, t;

bool check(int x){
    int l = 0x3f3f3f3f, r = 0;
    for(int i = 0; i <= k; ++i){
        if(trap[i].d > a[m-x+1]){
            l = min(trap[i].l, l);
            r = max(trap[i].r, r);
        }
    }
    return (n + 2*(r-l+1)) <= t;
}

int main(){

    scanf("%d%d%d%d", &m, &n, &k, &t);
    for(int i = 1; i <= m; ++i){
        scanf("%d", &a[i]);
    }
    for(int i = 1; i <= k; ++i){
        int l, r, d;
        scanf("%d%d%d", &trap[i].l, &trap[i].r, &trap[i].d);
    }

    sort(a+1, a+m);
    int l = 0, r = m;
    int ans = 0;
    while(l <= r){
        int mid = (l+r)/2;
        if(check(mid)){
            ans = mid;
            l = mid+1;
        }else{
            r = mid-1;
        }
    }
    printf("%d\n", ans);
}


#include<bits/stdc++.h>

using namespace std;

int a[200100];

struct T{
    int l, r ,d;
}trap[200100];

int n, m ,k, t;

bool check(int x){
    int l = 0x3f3f3f3f, r = 0;
    for(int i = 1; i <= k; ++i){
        if(trap[i].d > x){
            l = min(trap[i].l, l);
            r = max(trap[i].r, r);
        }
    }
    return (n + 2*(r-l+1)) < t;
}

int main(){

    scanf("%d%d%d%d", &m, &n, &k, &t);
    int M = 0;
    for(int i = 1; i <= m; ++i){
        scanf("%d", &a[i]);
        M = max(M, a[i]);
    }
    for(int i = 1; i <= k; ++i){
        scanf("%d%d%d", &trap[i].l, &trap[i].r, &trap[i].d);
    }

    int l = 1, r = M;
    int ans = 0x3f3f3f3f;
    while(l <= r){
        int mid = (l+r)/2;
        if(check(mid)){
            ans = mid;
            r = mid-1;
        }else{
            l = mid+1;
        }
    }
    int cnt = 0;
    for(int i = 1; i <= m; ++i){
        if(ans <= a[i]) cnt++;
    }
    printf("%d\n", cnt);
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<ll, ll> mpii;
typedef unordered_map<ll, ll> umpii;

#define pb(v) push_back(v)
#define all(v) v.begin(), v.end()
#define upb(v, key) (upper_bound(all(v), key) - v.begin())
#define lob(v, key) (lower_bound(all(v), key) - v.begin())

ll inf = 1e9;
ll INF = inf * inf;
ll mod = 1e9 + 7;
double eps = 1e-9;
const ld pi = ld(3.1415926535897932384626433832795);
ll dr[] = {-1, 0, 0, 1};
ll dc[] = {0, 1, -1, 0};

void mod_add(ll &a, ll b) {
  a += b;
  if(a >= mod) a -= mod;
}
void mod_sub(ll &a, ll b) {
  a -= b;
  if(a < 0) a += mod;
}
ll mod_pow(ll b, ll p) {
  ll res = 1;
  while(p) {
    if(p & 1) {
      res = res * b % mod;
    }
    p >>= 1;
    b = b * b % mod;
  }
  return res;
}

//only for variables and vectors;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define start_routine clock_t begin = clock();
#define end_routine                                                 \
  clock_t end = clock();                                            \
  double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;       \
  fprintf(stderr, "\nTime elapsed : %.3f seconds\n", elapsed_secs); \
  return 0;
/*...................................................*/

main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);

  ll ntraps, n, pts, sec, i, j, k, ans = 0;
  cin >> n >> pts >> ntraps >> sec;
  vi a(n);
  for(i = 0; i < n; i++) {
    cin >> a[i];
  }
  vi l(ntraps), r(ntraps), d(ntraps);
  for(i = 0; i < ntraps; i++) {
    cin >> l[i] >> r[i] >> d[i];
  }
  a.push_back(inf);
  sort(all(a), greater<>());
  ll lo = 0, hi = n + 1;
  while(hi - lo > 1) {
    ll mid = lo + hi >> 1;
    ll mx = 0, tot = n + 1;
    vii traps;
    for(i = 0; i < ntraps; i++) {
      if(d[i] > a[mid]) {
        traps.push_back(ii(l[i], r[i]));
      }
    }
    sort(all(traps));
    for(auto it: traps) {
      ll curl = it.first, curr = it.second;
      if(mx < curl) {
        tot += 2 * (curr - curl + 1);
        mx = curr;
      } else {
        tot += 2 * (max(0ll, curr - mx));
        mx = max(mx, curr);
      }
    }
    if(tot <= sec) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  cout << lo;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<ll, ll> mpii;
typedef unordered_map<ll, ll> umpii;

#define pb(v) push_back(v)
#define all(v) v.begin(), v.end()
#define upb(v, key) (upper_bound(all(v), key) - v.begin())
#define lob(v, key) (lower_bound(all(v), key) - v.begin())

ll inf = 1e9;
ll INF = inf * inf;
ll mod = 1e9 + 7;
double eps = 1e-9;
const ld pi = ld(3.1415926535897932384626433832795);
ll dr[] = {-1, 0, 0, 1};
ll dc[] = {0, 1, -1, 0};

void mod_add(ll &a, ll b) {
  a += b;
  if(a >= mod) a -= mod;
}
void mod_sub(ll &a, ll b) {
  a -= b;
  if(a < 0) a += mod;
}
ll mod_pow(ll b, ll p) {
  ll res = 1;
  while(p) {
    if(p & 1) {
      res = res * b % mod;
    }
    p >>= 1;
    b = b * b % mod;
  }
  return res;
}

//only for variables and vectors;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define start_routine clock_t begin = clock();
#define end_routine                                                 \
  clock_t end = clock();                                            \
  double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;       \
  fprintf(stderr, "\nTime elapsed : %.3f seconds\n", elapsed_secs); \
  return 0;
/*...................................................*/

main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);

  ll ntraps, n, pts, sec, i, j, k, ans = 0;
  cin >> n >> pts >> ntraps >> sec;
  vi a(n);
  for(i = 0; i < n; i++) {
    cin >> a[i];
  }
  vi l(ntraps), r(ntraps), d(ntraps);
  for(i = 0; i < ntraps; i++) {
    cin >> l[i] >> r[i] >> d[i];
  }
  // a.push_back(inf);
  sort(all(a), greater<>());
  ll lo = 0, hi = n;
  while(lo < hi) {
    ll mid = lo + hi + 1 >> 1;
    ll mx = 0, mn = inf, tot = n + 1;
    for(i = 0; i < mid; i++) {
      mn = min(mn, a[i]);
    }
    vii traps;
    for(i = 0; i < ntraps; i++) {
      if(d[i] > mn) {
        traps.push_back(ii(l[i], r[i]));
      }
    }
    sort(all(traps));
    for(auto it: traps) {
      ll curl = it.first, curr = it.second;
      if(mx < curl) {
        tot += 2 * (curr - curl + 1);
        mx = curr;
      } else {
        tot += 2 * (max(0ll, curr - mx));
        mx = max(mx, curr);
      }
    }
    if(tot <= sec) {
      lo = mid;
    } else {
      hi = mid - 1;
    }
  }
  cout << lo;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<ll, ll> mpii;
typedef unordered_map<ll, ll> umpii;

#define pb(v) push_back(v)
#define all(v) v.begin(), v.end()
#define upb(v, key) (upper_bound(all(v), key) - v.begin())
#define lob(v, key) (lower_bound(all(v), key) - v.begin())

ll inf = 1e9;
ll INF = inf * inf;
ll mod = 1e9 + 7;
double eps = 1e-9;
const ld pi = ld(3.1415926535897932384626433832795);
ll dr[] = {-1, 0, 0, 1};
ll dc[] = {0, 1, -1, 0};

void mod_add(ll &a, ll b) {
  a += b;
  if(a >= mod) a -= mod;
}
void mod_sub(ll &a, ll b) {
  a -= b;
  if(a < 0) a += mod;
}
ll mod_pow(ll b, ll p) {
  ll res = 1;
  while(p) {
    if(p & 1) {
      res = res * b % mod;
    }
    p >>= 1;
    b = b * b % mod;
  }
  return res;
}

//only for variables and vectors;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define start_routine clock_t begin = clock();
#define end_routine                                                 \
  clock_t end = clock();                                            \
  double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;       \
  fprintf(stderr, "\nTime elapsed : %.3f seconds\n", elapsed_secs); \
  return 0;
/*...................................................*/

main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);

  ll ntraps, n, pts, sec, i, j, k;
  cin >> n >> pts >> ntraps >> sec;
  vi a(n);
  for(i = 0; i < n; i++) {
    cin >> a[i];
  }
  vi l(ntraps), r(ntraps), d(ntraps);
  for(i = 0; i < ntraps; i++) {
    cin >> l[i] >> r[i] >> d[i];
  }
  a.push_back(inf);
  sort(all(a), greater<>());
  ll ans;
  for(ll mid = 0; mid <= n; mid++) {
    ll mx = 0, tot = n + 1;
    vii traps;
    for(i = 0; i < ntraps; i++) {
      if(d[i] > a[mid]) {
        traps.push_back(ii(l[i], r[i]));
      }
    }
    sort(all(traps));
    for(auto it: traps) {
      ll curl = it.first, curr = it.second;
      if(mx >= curl) {
        tot += 2 * max(0ll, curr - mx);
      } else {
        tot += 2 * (curr - curl + 1);
      }
      mx = max(mx, curr);
    }
    if(tot > sec) {
      break;
    }
    ans = mid;
  }
  cout << ans;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<ll, ll> mpii;
typedef unordered_map<ll, ll> umpii;

#define pb(v) push_back(v)
#define all(v) v.begin(), v.end()
#define upb(v, key) (upper_bound(all(v), key) - v.begin())
#define lob(v, key) (lower_bound(all(v), key) - v.begin())

ll inf = 1e9;
ll INF = inf * inf;
ll mod = 1e9 + 7;
double eps = 1e-9;
const ld pi = ld(3.1415926535897932384626433832795);
ll dr[] = {-1, 0, 0, 1};
ll dc[] = {0, 1, -1, 0};

void mod_add(ll &a, ll b) {
  a += b;
  if(a >= mod) a -= mod;
}
void mod_sub(ll &a, ll b) {
  a -= b;
  if(a < 0) a += mod;
}
ll mod_pow(ll b, ll p) {
  ll res = 1;
  while(p) {
    if(p & 1) {
      res = res * b % mod;
    }
    p >>= 1;
    b = b * b % mod;
  }
  return res;
}

//only for variables and vectors;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define start_routine clock_t begin = clock();
#define end_routine                                                 \
  clock_t end = clock();                                            \
  double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;       \
  fprintf(stderr, "\nTime elapsed : %.3f seconds\n", elapsed_secs); \
  return 0;
/*...................................................*/

main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);

  ll ntraps, n, pts, sec, i, j, k, ans = 0, maxn = 2e5 + 10;
  cin >> n >> pts >> ntraps >> sec;
  vi a(n);
  for(i = 0; i < n; i++) {
    cin >> a[i];
  }
  vi mark(maxn, -1), r(ntraps), d(ntraps);
  for(i = 0; i < ntraps; i++) {
    ll l;
    cin >> l >> r[i] >> d[i];
    mark[l] = i;
  }
  a.push_back(inf);
  sort(all(a), greater<>());
  ll lo = 0, hi = n;
  while(lo < hi) {
    ll mid = lo + hi + 1 >> 1;
    ll mx = 0, tot = n + 1;
    for(ll pos = 1; pos < maxn; pos++) {
      if(mark[pos] == -1) {
        continue;
      }
      ll id = mark[pos];
      if(d[id] <= a[mid]) {
        continue;
      }
      if(mx < pos) {
        tot += 2 * (r[id] - mx + 1);
        mx = r[id];
      } else {
        tot += 2 * (max(0ll, mx - r[id]));
        mx = max(mx, r[id]);
      }
    }
    if(tot <= sec) {
      lo = mid;
    } else {
      hi = mid - 1;
    }
  }
  cout << lo;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<ll, ll> mpii;
typedef unordered_map<ll, ll> umpii;

#define pb(v) push_back(v)
#define all(v) v.begin(), v.end()
#define upb(v, key) (upper_bound(all(v), key) - v.begin())
#define lob(v, key) (lower_bound(all(v), key) - v.begin())

ll inf = 1e9;
ll INF = inf * inf;
ll mod = 1e9 + 7;
double eps = 1e-9;
const ld pi = ld(3.1415926535897932384626433832795);
ll dr[] = {-1, 0, 0, 1};
ll dc[] = {0, 1, -1, 0};

void mod_add(ll &a, ll b) {
  a += b;
  if(a >= mod) a -= mod;
}
void mod_sub(ll &a, ll b) {
  a -= b;
  if(a < 0) a += mod;
}
ll mod_pow(ll b, ll p) {
  ll res = 1;
  while(p) {
    if(p & 1) {
      res = res * b % mod;
    }
    p >>= 1;
    b = b * b % mod;
  }
  return res;
}

//only for variables and vectors;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define start_routine clock_t begin = clock();
#define end_routine                                                 \
  clock_t end = clock();                                            \
  double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;       \
  fprintf(stderr, "\nTime elapsed : %.3f seconds\n", elapsed_secs); \
  return 0;
/*...................................................*/

main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);

  ll ntraps, n, pts, sec, i, j, k, ans = 0, maxn = 2e5 + 10;
  cin >> n >> pts >> ntraps >> sec;
  vi a(n);
  for(i = 0; i < n; i++) {
    cin >> a[i];
  }
  vi mark(maxn, -1), r(ntraps), d(ntraps);
  for(i = 0; i < ntraps; i++) {
    ll l;
    cin >> l >> r[i] >> d[i];
    mark[l] = i;
  }
  a.push_back(inf);
  sort(all(a), greater<>());
  ll lo = 0, hi = n;
  while(lo < hi) {
    ll mid = lo + hi + 1 >> 1;
    ll mx = 0, tot = n + 1;
    for(ll pos = 1; pos < maxn; pos++) {
      if(mark[pos] == -1) {
        continue;
      }
      ll id = mark[pos];
      if(d[id] <= a[mid]) {
        continue;
      }
      if(mx < pos) {
        tot += 2;
        mx = pos;
      }

      tot += max(0ll, (r[id] - mx) * 2);
      mx = max(mx, r[id]);
    }
    if(tot <= sec) {
      lo = mid;
    } else {
      hi = mid - 1;
    }
  }
  cout << lo;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<ll, ll> mpii;
typedef unordered_map<ll, ll> umpii;

#define pb(v) push_back(v)
#define all(v) v.begin(), v.end()
#define upb(v, key) (upper_bound(all(v), key) - v.begin())
#define lob(v, key) (lower_bound(all(v), key) - v.begin())

ll inf = 1e9;
ll INF = inf * inf;
ll mod = 1e9 + 7;
double eps = 1e-9;
const ld pi = ld(3.1415926535897932384626433832795);
ll dr[] = {-1, 0, 0, 1};
ll dc[] = {0, 1, -1, 0};

void mod_add(ll &a, ll b) {
  a += b;
  if(a >= mod) a -= mod;
}
void mod_sub(ll &a, ll b) {
  a -= b;
  if(a < 0) a += mod;
}
ll mod_pow(ll b, ll p) {
  ll res = 1;
  while(p) {
    if(p & 1) {
      res = res * b % mod;
    }
    p >>= 1;
    b = b * b % mod;
  }
  return res;
}

//only for variables and vectors;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define start_routine clock_t begin = clock();
#define end_routine                                                 \
  clock_t end = clock();                                            \
  double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;       \
  fprintf(stderr, "\nTime elapsed : %.3f seconds\n", elapsed_secs); \
  return 0;
/*...................................................*/

main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);

  ll ntraps, n, pts, sec, i, j, k, ans = 0;
  cin >> n >> pts >> ntraps >> sec;
  vi a(n);
  for(i = 0; i < n; i++) {
    cin >> a[i];
  }
  vi l(ntraps), r(ntraps), d(ntraps);
  for(i = 0; i < ntraps; i++) {
    cin >> l[i] >> r[i] >> d[i];
  }
  // a.push_back(inf);
  sort(all(a), greater<>());
  ll lo = 0, hi = n;
  while(lo < hi) {
    ll mid = lo + hi + 1 >> 1;
    ll mx = 0, mn = inf, tot = n + 1;
    for(i = 0; i < mid; i++) {
      mn = min(mn, a[i]);
    }
    vii traps;
    for(i = 0; i < ntraps; i++) {
      if(d[i] > a[mid]) {
        traps.push_back(ii(l[i], r[i]));
      }
    }
    sort(all(traps));
    for(auto it: traps) {
      ll curl = it.first, curr = it.second;
      if(mx < curl) {
        tot += 2 * (curr - curl + 1);
        mx = curr;
      } else {
        tot += 2 * (max(0ll, curr - mx));
        mx = max(mx, curr);
      }
    }
    if(tot <= sec) {
      lo = mid;
    } else {
      hi = mid - 1;
    }
  }
  cout << lo;
}


#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

typedef pair<int, int> pt;

#define x first
#define y second

int m, n, k, t;
vector<int> l, r, d, a;

bool can(int x)
{
	int mn = int(1e9);
	for (int i = 0; i < x; i++)
		mn = min(mn, a[i]);
	vector<pt> segm;
	for (int i = 0; i < k; i++)
		if (d[i] > mn)
			segm.push_back(make_pair(l[i], r[i]));
	int req_time = 0;
	sort(segm.begin(), segm.end());
	int lastr = 0;
	for (auto s : segm)
	{
		if (s.x <= lastr)
		{
			req_time += max(0, s.y - lastr);
			lastr = max(s.y, lastr);
		}
		else
		{
			req_time += s.y - s.x + 1;
			lastr = s.y;
		}
	}
	req_time = 2 * req_time + n + 1;
	return req_time <= t;
}

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d %d %d %d", &m, &n, &k, &t);
	a.resize(m);
	for (int i = 0; i < m; i++)
		scanf("%d", &a[i]);
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	l.resize(k);
	r.resize(k);
	d.resize(k);
	for (int i = 0; i < k; i++)
		scanf("%d %d %d", &l[i], &r[i], &d[i]);

	int lf = 0;
	int rg = m + 1;
	while (rg - lf > 1)
	{
		int mid = (lf + rg) / 2;
		if (can(mid))
			lf = mid;
		else
			rg = mid;
	}
	printf("%d\n", lf);
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<ll, ll> mpii;
typedef unordered_map<ll, ll> umpii;

#define pb(v) push_back(v)
#define all(v) v.begin(), v.end()
#define upb(v, key) (upper_bound(all(v), key) - v.begin())
#define lob(v, key) (lower_bound(all(v), key) - v.begin())

ll inf = 1e9;
ll INF = inf * inf;
ll mod = 1e9 + 7;
double eps = 1e-9;
const ld pi = ld(3.1415926535897932384626433832795);
ll dr[] = {-1, 0, 0, 1};
ll dc[] = {0, 1, -1, 0};

void mod_add(ll &a, ll b) {
  a += b;
  if(a >= mod) a -= mod;
}
void mod_sub(ll &a, ll b) {
  a -= b;
  if(a < 0) a += mod;
}
ll mod_pow(ll b, ll p) {
  ll res = 1;
  while(p) {
    if(p & 1) {
      res = res * b % mod;
    }
    p >>= 1;
    b = b * b % mod;
  }
  return res;
}

//only for variables and vectors;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define start_routine clock_t begin = clock();
#define end_routine                                                 \
  clock_t end = clock();                                            \
  double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;       \
  fprintf(stderr, "\nTime elapsed : %.3f seconds\n", elapsed_secs); \
  return 0;
/*...................................................*/

main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);

  ll ntraps, n, pts, sec, i, j, k, ans = 0, maxn = 2e5 + 10;
  cin >> n >> pts >> ntraps >> sec;
  vi a(n);
  for(i = 0; i < n; i++) {
    cin >> a[i];
  }
  vi mark(maxn, -1), r(ntraps), d(ntraps);
  for(i = 0; i < ntraps; i++) {
    ll l;
    cin >> l >> r[i] >> d[i];
    mark[l] = i;
  }
  a.push_back(inf);
  sort(all(a), greater<>());
  ll lo = 0, hi = n;
  while(lo < hi) {
    ll mid = lo + hi + 1 >> 1;
    ll mx = 0, tot = n + 1;
    for(ll pos = 1; pos < maxn; pos++) {
      if(mark[pos] == -1) {
        continue;
      }
      ll id = mark[pos];
      if(d[id] <= a[mid]) {
        continue;
      }
      if(mx < pos) {
        tot += 2 * (r[id] - pos + 1);
        mx = r[id];
      } else {
        tot += 2 * (max(0ll, mx - r[id]));
        mx = max(mx, r[id]);
      }
    }
    if(tot <= sec) {
      lo = mid;
    } else {
      hi = mid - 1;
    }
  }
  cout << lo;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<ll, ll> mpii;
typedef unordered_map<ll, ll> umpii;

#define pb(v) push_back(v)
#define all(v) v.begin(), v.end()
#define upb(v, key) (upper_bound(all(v), key) - v.begin())
#define lob(v, key) (lower_bound(all(v), key) - v.begin())

ll inf = 1e9;
ll INF = inf * inf;
ll mod = 1e9 + 7;
double eps = 1e-9;
const ld pi = ld(3.1415926535897932384626433832795);
ll dr[] = {-1, 0, 0, 1};
ll dc[] = {0, 1, -1, 0};

void mod_add(ll &a, ll b) {
  a += b;
  if(a >= mod) a -= mod;
}
void mod_sub(ll &a, ll b) {
  a -= b;
  if(a < 0) a += mod;
}
ll mod_pow(ll b, ll p) {
  ll res = 1;
  while(p) {
    if(p & 1) {
      res = res * b % mod;
    }
    p >>= 1;
    b = b * b % mod;
  }
  return res;
}

//only for variables and vectors;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define start_routine clock_t begin = clock();
#define end_routine                                                 \
  clock_t end = clock();                                            \
  double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;       \
  fprintf(stderr, "\nTime elapsed : %.3f seconds\n", elapsed_secs); \
  return 0;
/*...................................................*/

main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);

  ll ntraps, n, pts, sec, i, j, k, ans = 0, maxn = 2e5 + 10;
  cin >> n >> pts >> ntraps >> sec;
  vi a(n);
  for(i = 0; i < n; i++) {
    cin >> a[i];
  }
  vi mark(maxn, -1), r(ntraps), d(ntraps);
  for(i = 0; i < ntraps; i++) {
    ll l;
    cin >> l >> r[i] >> d[i];
    mark[l] = i;
  }
  a.push_back(inf);
  sort(all(a), greater<>());
  ll lo = 0, hi = n;
  while(lo < hi) {
    ll mid = lo + hi + 1 >> 1;
    ll mx = 0, tot = pts + 1;
    for(ll pos = 1; pos < maxn; pos++) {
      if(mark[pos] == -1) {
        continue;
      }
      ll id = mark[pos];
      if(d[id] <= a[mid]) {
        continue;
      }
      if(mx < pos) {
        tot += 2;
        mx = pos;
      }

      tot += max(0ll, (r[id] - mx) * 2);
      mx = max(mx, r[id]);
    }
    if(tot <= sec) {
      lo = mid;
    } else {
      hi = mid - 1;
    }
  }
  cout << lo;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<ll, ll> mpii;
typedef unordered_map<ll, ll> umpii;

#define pb(v) push_back(v)
#define all(v) v.begin(), v.end()
#define upb(v, key) (upper_bound(all(v), key) - v.begin())
#define lob(v, key) (lower_bound(all(v), key) - v.begin())

ll inf = 1e9;
ll INF = inf * inf;
ll mod = 1e9 + 7;
double eps = 1e-9;
const ld pi = ld(3.1415926535897932384626433832795);
ll dr[] = {-1, 0, 0, 1};
ll dc[] = {0, 1, -1, 0};

void mod_add(ll &a, ll b) {
  a += b;
  if(a >= mod) a -= mod;
}
void mod_sub(ll &a, ll b) {
  a -= b;
  if(a < 0) a += mod;
}
ll mod_pow(ll b, ll p) {
  ll res = 1;
  while(p) {
    if(p & 1) {
      res = res * b % mod;
    }
    p >>= 1;
    b = b * b % mod;
  }
  return res;
}

//only for variables and vectors;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define start_routine clock_t begin = clock();
#define end_routine                                                 \
  clock_t end = clock();                                            \
  double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;       \
  fprintf(stderr, "\nTime elapsed : %.3f seconds\n", elapsed_secs); \
  return 0;
/*...................................................*/

main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);

  ll ntraps, n, pts, sec, i, j, k, ans = 0;
  cin >> n >> pts >> ntraps >> sec;
  vi a(n);
  for(i = 0; i < n; i++) {
    cin >> a[i];
  }
  vi l(ntraps), r(ntraps), d(ntraps);
  for(i = 0; i < ntraps; i++) {
    cin >> l[i] >> r[i] >> d[i];
  }
  a.push_back(inf);
  sort(all(a), greater<>());
  ll lo = 0, hi = n;
  while(lo < hi) {
    ll mid = lo + hi + 1 >> 1;
    ll mx = 0, tot = pts + 1;
    vii traps;
    for(i = 0; i < ntraps; i++) {
      if(d[i] > a[mid]) {
        traps.push_back(ii(l[i], r[i]));
      }
    }
    sort(all(traps));
    for(auto it: traps) {
      ll curl = it.first, curr = it.second;
      if(mx < curl) {
        tot += 2 * (curr - curl + 1);
        mx = curr;
      } else {
        tot += 2 * (max(0ll, curr - mx));
        mx = max(mx, curr);
      }
    }
    if(tot <= sec) {
      lo = mid;
    } else {
      hi = mid - 1;
    }
  }
  cout << lo;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<ll, ll> mpii;
typedef unordered_map<ll, ll> umpii;

#define pb(v) push_back(v)
#define all(v) v.begin(), v.end()
#define upb(v, key) (upper_bound(all(v), key) - v.begin())
#define lob(v, key) (lower_bound(all(v), key) - v.begin())

ll inf = 1e9;
ll INF = inf * inf;
ll mod = 1e9 + 7;
double eps = 1e-9;
const ld pi = ld(3.1415926535897932384626433832795);
ll dr[] = {-1, 0, 0, 1};
ll dc[] = {0, 1, -1, 0};

void mod_add(ll &a, ll b) {
  a += b;
  if(a >= mod) a -= mod;
}
void mod_sub(ll &a, ll b) {
  a -= b;
  if(a < 0) a += mod;
}
ll mod_pow(ll b, ll p) {
  ll res = 1;
  while(p) {
    if(p & 1) {
      res = res * b % mod;
    }
    p >>= 1;
    b = b * b % mod;
  }
  return res;
}

//only for variables and vectors;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define start_routine clock_t begin = clock();
#define end_routine                                                 \
  clock_t end = clock();                                            \
  double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;       \
  fprintf(stderr, "\nTime elapsed : %.3f seconds\n", elapsed_secs); \
  return 0;
/*...................................................*/

main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);

  ll ntraps, n, pts, sec, i, j, k, ans = 0;
  cin >> n >> pts >> ntraps >> sec;
  vi a(n);
  for(i = 0; i < n; i++) {
    cin >> a[i];
  }
  vi l(ntraps), r(ntraps), d(ntraps);
  for(i = 0; i < ntraps; i++) {
    cin >> l[i] >> r[i] >> d[i];
  }
  // a.push_back(inf);
  sort(all(a), greater<>());
  ll lo = 0, hi = n + 1;
  while(hi - lo > 1) {
    ll mid = lo + hi >> 1;
    ll mx = 0, mn = inf, tot = n + 1;
    for(i = 0; i < mid; i++) {
      mn = min(mn, a[i]);
    }
    vii traps;
    for(i = 0; i < ntraps; i++) {
      if(d[i] > a[mid]) {
        traps.push_back(ii(l[i], r[i]));
      }
    }
    sort(all(traps));
    for(auto it: traps) {
      ll curl = it.first, curr = it.second;
      if(mx < curl) {
        tot += 2 * (curr - curl + 1);
        mx = curr;
      } else {
        tot += 2 * (max(0ll, curr - mx));
        mx = max(mx, curr);
      }
    }
    if(tot <= sec) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  cout << lo;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<ll, ll> mpii;
typedef unordered_map<ll, ll> umpii;

#define pb(v) push_back(v)
#define all(v) v.begin(), v.end()
#define upb(v, key) (upper_bound(all(v), key) - v.begin())
#define lob(v, key) (lower_bound(all(v), key) - v.begin())

ll inf = 1e9;
ll INF = inf * inf;
ll mod = 1e9 + 7;
double eps = 1e-9;
const ld pi = ld(3.1415926535897932384626433832795);
ll dr[] = {-1, 0, 0, 1};
ll dc[] = {0, 1, -1, 0};

void mod_add(ll &a, ll b) {
  a += b;
  if(a >= mod) a -= mod;
}
void mod_sub(ll &a, ll b) {
  a -= b;
  if(a < 0) a += mod;
}
ll mod_pow(ll b, ll p) {
  ll res = 1;
  while(p) {
    if(p & 1) {
      res = res * b % mod;
    }
    p >>= 1;
    b = b * b % mod;
  }
  return res;
}

//only for variables and vectors;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define start_routine clock_t begin = clock();
#define end_routine                                                 \
  clock_t end = clock();                                            \
  double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;       \
  fprintf(stderr, "\nTime elapsed : %.3f seconds\n", elapsed_secs); \
  return 0;
/*...................................................*/

main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);

  ll ntraps, n, pts, sec, i, j, k, ans = 0;
  cin >> n >> pts >> ntraps >> sec;
  vi a(n);
  for(i = 0; i < n; i++) {
    cin >> a[i];
  }
  vi l(ntraps), r(ntraps), d(ntraps);
  for(i = 0; i < ntraps; i++) {
    cin >> l[i] >> r[i] >> d[i];
  }
  // a.push_back(inf);
  sort(all(a), greater<>());
  ll lo = 0, hi = n + 1;
  while(lo < hi) {
    ll mid = lo + hi + 1 >> 1;
    ll mx = 0, mn = inf, tot = n + 1;
    for(i = 0; i < mid; i++) {
      mn = min(mn, a[i]);
    }
    vii traps;
    for(i = 0; i < ntraps; i++) {
      if(d[i] > mn) {
        traps.push_back(ii(l[i], r[i]));
      }
    }
    sort(all(traps));
    for(auto it: traps) {
      ll curl = it.first, curr = it.second;
      if(mx < curl) {
        tot += 2 * (curr - curl + 1);
        mx = curr;
      } else {
        tot += 2 * (max(0ll, curr - mx));
        mx = max(mx, curr);
      }
    }
    if(tot <= sec) {
      lo = mid;
    } else {
      hi = mid - 1;
    }
  }
  cout << lo;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<ll, ll> mpii;
typedef unordered_map<ll, ll> umpii;

#define pb(v) push_back(v)
#define all(v) v.begin(), v.end()
#define upb(v, key) (upper_bound(all(v), key) - v.begin())
#define lob(v, key) (lower_bound(all(v), key) - v.begin())

ll inf = 1e9;
ll INF = inf * inf;
ll mod = 1e9 + 7;
double eps = 1e-9;
const ld pi = ld(3.1415926535897932384626433832795);
ll dr[] = {-1, 0, 0, 1};
ll dc[] = {0, 1, -1, 0};

void mod_add(ll &a, ll b) {
  a += b;
  if(a >= mod) a -= mod;
}
void mod_sub(ll &a, ll b) {
  a -= b;
  if(a < 0) a += mod;
}
ll mod_pow(ll b, ll p) {
  ll res = 1;
  while(p) {
    if(p & 1) {
      res = res * b % mod;
    }
    p >>= 1;
    b = b * b % mod;
  }
  return res;
}

//only for variables and vectors;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define start_routine clock_t begin = clock();
#define end_routine                                                 \
  clock_t end = clock();                                            \
  double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;       \
  fprintf(stderr, "\nTime elapsed : %.3f seconds\n", elapsed_secs); \
  return 0;
/*...................................................*/

main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);

  ll ntraps, n, pts, sec, i, j, k, ans = 0;
  cin >> n >> pts >> ntraps >> sec;
  vi a(n);
  for(i = 0; i < n; i++) {
    cin >> a[i];
  }
  vi l(ntraps), r(ntraps), d(ntraps);
  for(i = 0; i < ntraps; i++) {
    cin >> l[i] >> r[i] >> d[i];
  }
  a.push_back(inf);
  sort(all(a), greater<>());
  ll lo = 0, hi = n;
  while(lo < hi) {
    ll mid = lo + hi + 1 >> 1;
    ll mx = 0, tot = pts + 1;
    vii traps;
    for(i = 0; i < ntraps; i++) {
      if(d[i] > a[mid]) {
        traps.push_back(ii(l[i], r[i]));
      }
    }
    sort(all(traps));
    for(auto it: traps) {
      ll curl = it.first, curr = it.second;
      if(mx < curl) {
        mx = curl;
        tot += 2;
      }
      tot += 2 * max(0ll, curr - mx);
      mx = max(mx, curr);
    }
    if(tot <= sec) {
      lo = mid;
    } else {
      hi = mid - 1;
    }
  }
  cout << lo;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<ll, ll> mpii;
typedef unordered_map<ll, ll> umpii;

#define pb(v) push_back(v)
#define all(v) v.begin(), v.end()
#define upb(v, key) (upper_bound(all(v), key) - v.begin())
#define lob(v, key) (lower_bound(all(v), key) - v.begin())

ll inf = 1e9;
ll INF = inf * inf;
ll mod = 1e9 + 7;
double eps = 1e-9;
const ld pi = ld(3.1415926535897932384626433832795);
ll dr[] = {-1, 0, 0, 1};
ll dc[] = {0, 1, -1, 0};

void mod_add(ll &a, ll b) {
  a += b;
  if(a >= mod) a -= mod;
}
void mod_sub(ll &a, ll b) {
  a -= b;
  if(a < 0) a += mod;
}
ll mod_pow(ll b, ll p) {
  ll res = 1;
  while(p) {
    if(p & 1) {
      res = res * b % mod;
    }
    p >>= 1;
    b = b * b % mod;
  }
  return res;
}

//only for variables and vectors;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define start_routine clock_t begin = clock();
#define end_routine                                                 \
  clock_t end = clock();                                            \
  double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;       \
  fprintf(stderr, "\nTime elapsed : %.3f seconds\n", elapsed_secs); \
  return 0;
/*...................................................*/

main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);

  ll ntraps, n, pts, sec, i, j, k, ans = 0, maxn = 2e5 + 10;
  cin >> n >> pts >> ntraps >> sec;
  vi a(n);
  for(i = 0; i < n; i++) {
    cin >> a[i];
  }
  vi mark(maxn, -1), r(ntraps), d(ntraps);
  for(i = 0; i < ntraps; i++) {
    ll l;
    cin >> l >> r[i] >> d[i];
    mark[l] = i;
  }
  a.push_back(inf);
  sort(all(a), greater<>());
  ll lo = 0, hi = n;
  while(lo < hi) {
    ll mid = lo + hi + 1 >> 1;
    ll mx = 0, tot = n + 1;
    for(ll pos = 1; pos < maxn; pos++) {
      if(mark[pos] == -1) {
        continue;
      }
      ll id = mark[pos];
      if(d[id] <= a[mid]) {
        continue;
      }
      mx = max(mx, pos);
      tot += max(0ll, (r[id] - mx + 1) * 2);
      mx = max(mx, r[id]);
    }
    if(tot <= sec) {
      lo = mid;
    } else {
      hi = mid - 1;
    }
  }
  cout << lo;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<ll, ll> mpii;
typedef unordered_map<ll, ll> umpii;

#define pb(v) push_back(v)
#define all(v) v.begin(), v.end()
#define upb(v, key) (upper_bound(all(v), key) - v.begin())
#define lob(v, key) (lower_bound(all(v), key) - v.begin())

ll inf = 1e9;
ll INF = inf * inf;
ll mod = 1e9 + 7;
double eps = 1e-9;
const ld pi = ld(3.1415926535897932384626433832795);
ll dr[] = {-1, 0, 0, 1};
ll dc[] = {0, 1, -1, 0};

void mod_add(ll &a, ll b) {
  a += b;
  if(a >= mod) a -= mod;
}
void mod_sub(ll &a, ll b) {
  a -= b;
  if(a < 0) a += mod;
}
ll mod_pow(ll b, ll p) {
  ll res = 1;
  while(p) {
    if(p & 1) {
      res = res * b % mod;
    }
    p >>= 1;
    b = b * b % mod;
  }
  return res;
}

//only for variables and vectors;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define start_routine clock_t begin = clock();
#define end_routine                                                 \
  clock_t end = clock();                                            \
  double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;       \
  fprintf(stderr, "\nTime elapsed : %.3f seconds\n", elapsed_secs); \
  return 0;
/*...................................................*/

main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);

  ll ntraps, n, pts, sec, i, j, k, ans = 0, maxn = 2e5 + 10;
  cin >> n >> pts >> ntraps >> sec;
  vi a(n);
  for(i = 0; i < n; i++) {
    cin >> a[i];
  }
  vi mark(maxn, -1), r(ntraps), d(ntraps);
  for(i = 0; i < ntraps; i++) {
    ll l;
    cin >> l >> r[i] >> d[i];
    mark[l] = i;
  }
  a.push_back(inf);
  sort(all(a), greater<>());
  ll lo = 0, hi = n;
  while(lo < hi) {
    ll mid = lo + hi + 1 >> 1;
    ll mx = 0, tot = n + 1;
    for(ll pos = 1; pos < maxn; pos++) {
      if(mark[pos] == -1) {
        continue;
      }
      ll id = mark[pos];
      if(d[id] <= a[mid]) {
        continue;
      }
      if(mx < pos) {
        tot++;
        mx = pos;
      }

      tot += max(0ll, (r[id] - mx + 1) * 2);
      mx = max(mx, r[id]);
    }
    if(tot <= sec) {
      lo = mid;
    } else {
      hi = mid - 1;
    }
  }
  cout << lo;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<ll, ll> mpii;
typedef unordered_map<ll, ll> umpii;

#define pb(v) push_back(v)
#define all(v) v.begin(), v.end()
#define upb(v, key) (upper_bound(all(v), key) - v.begin())
#define lob(v, key) (lower_bound(all(v), key) - v.begin())

ll inf = 1e9;
ll INF = inf * inf;
ll mod = 1e9 + 7;
double eps = 1e-9;
const ld pi = ld(3.1415926535897932384626433832795);
ll dr[] = {-1, 0, 0, 1};
ll dc[] = {0, 1, -1, 0};

void mod_add(ll &a, ll b) {
  a += b;
  if(a >= mod) a -= mod;
}
void mod_sub(ll &a, ll b) {
  a -= b;
  if(a < 0) a += mod;
}
ll mod_pow(ll b, ll p) {
  ll res = 1;
  while(p) {
    if(p & 1) {
      res = res * b % mod;
    }
    p >>= 1;
    b = b * b % mod;
  }
  return res;
}

//only for variables and vectors;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define start_routine clock_t begin = clock();
#define end_routine                                                 \
  clock_t end = clock();                                            \
  double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;       \
  fprintf(stderr, "\nTime elapsed : %.3f seconds\n", elapsed_secs); \
  return 0;
/*...................................................*/

main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);

  ll ntraps, n, pts, sec, i, j, k, ans = 0;
  cin >> n >> pts >> ntraps >> sec;
  vi a(n);
  for(i = 0; i < n; i++) {
    cin >> a[i];
  }
  vi l(ntraps), r(ntraps), d(ntraps);
  for(i = 0; i < ntraps; i++) {
    cin >> l[i] >> r[i] >> d[i];
  }
  // a.push_back(inf);
  sort(all(a), greater<>());
  ll lo = 0, hi = n + 1;
  while(hi - lo > 1) {
    ll mid = lo + hi >> 1;
    ll mx = 0, mn = inf, tot = n + 1;
    for(i = 0; i < mid; i++) {
      mn = min(mn, a[i]);
    }
    vii traps;
    for(i = 0; i < ntraps; i++) {
      if(d[i] > mn) {
        traps.push_back(ii(l[i], r[i]));
      }
    }
    sort(all(traps));
    for(auto it: traps) {
      ll curl = it.first, curr = it.second;
      if(mx < curl) {
        tot += 2 * (curr - curl + 1);
        mx = curr;
      } else {
        tot += 2 * (max(0ll, curr - mx));
        mx = max(mx, curr);
      }
    }
    if(tot <= sec) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  cout << lo;
}


import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class Review4 {

	public static void main(String[] args) {
		Scanner UserInput = new Scanner(System.in);
		int num = UserInput.nextInt();
		ArrayList<Integer> list = new ArrayList<>(num);
		ArrayList<Integer> sorted = new ArrayList<>(num);
		for (int i = 0; i < num; i++) {
			int temp = UserInput.nextInt();
			list.add(temp);
			sorted.add(temp);
		}
		Collections.sort(sorted);
		int count1 = 0;
		int count2 = num - 1;
		while ((count1 < num) && (list.get(count1).equals(sorted.get(count1))))
			count1++;
		if (count1 == num) {
			System.out.println("yes");
			System.out.println(1 + " " + 1);
			System.exit(0);
		}

		while ((count2 >= 0) && (list.get(count2).equals(sorted.get(count2))))
			count2--;
		ArrayList<Integer> last = new ArrayList<>(num);
		for (int i = 0; i < count1; i++)
			last.add(list.get(i));
		for (int i = count2; i >= count1; i--)
			last.add(list.get(i));
		for (int i = count2 + 1; i < num; i++)
			last.add(list.get(i));

		for (int i = 0; i < num; i++) {
			if (!last.get(i).equals(sorted.get(i))) {
				System.out.println("no");
				System.exit(0);
			}
		}
		System.out.println("yes");
		System.out.println((count1 + 1) + " " + (count2 + 1));
		UserInput.close();
	}

}


import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner (System.in);

		try {
			int size         = scanner.nextInt ();
			Integer[] raw    = new Integer[size];
			Integer[] sorted = new Integer[size];

			for (int index = 0; index < size; index++) { // O(N)
				raw[index]    = scanner.nextInt ();
				sorted[index] = raw[index];
			}

			Arrays.sort (sorted, new Comparator<Integer> () { // O (NlogN)
				@Override
				public int compare (Integer number1,
									Integer number2) {
					return number1.compareTo (number2);
				}
			});

			int left = -1, right = -1;

			for (int index = 0; index < size; index++) { // O (N)
				if (sorted[index] != raw[index]) {
					if (left == -1) {
						left  = index;
					} else {
						right = index;
					}
				}
			}

			if (left == -1 && right == -1) {
				System.out.println ("yes");
				System.out.println ("1 1");
				return;
			}

			for (int indexLeft = left, indexRight = right; indexLeft < indexRight; indexLeft++, indexRight--) { // O (right - 1)
				int swap        = raw[indexLeft];
				raw[indexLeft]  = raw[indexRight];
				raw[indexRight] = swap;
			}

			for (int index = left; index < right; index++) { // O (right - 1)
				if (sorted[index] != raw[index]) {
					System.out.println ("no");
					return;
				}
			}

			System.out.println ("yes");
			System.out.println ((left + 1) + " " + (right + 1));

			return;
		} catch (Exception ex) {
			ex.printStackTrace ();
		} finally {
			scanner.close ();
		}
	}
}


import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner (System.in);

		try {
			int size = scanner.nextInt ();
			Integer[] array = new Integer [size];
			Integer[] temp  = new Integer [size];
			int[] out       = new int[2];

			for (int index = 0; index < array.length; index++) { // O (N)
				array[index] = scanner.nextInt ();
				temp[index]  = array[index];
			}

			Arrays.sort (array, new Comparator <Integer> () { // O (NlogN)

				@Override
				public int compare (Integer number1,
									Integer number2) {
					return number1.compareTo (number2);
				}
			});

			for (int index = 0; index < array.length; index++) {
				if (temp[index] != array[index]) {
					if (out[0] == 0) {
						out[0] = temp[index];

					} else if (out[1] == 0) {
						out[1] = temp[index];

					} else {
						System.out.println ("no");
						return;
					}
				}
			}

			if (out[0] == 0 && out[1] == 0) {
				out[0] = temp[0];
				out[1] = temp[0];
			}

			System.out.println ("yes");
			System.out.println (out[0] > out[1] ? out[1] + " " + out[0] : out[0] + " " + out[1]);

			return;
		} catch (Exception ex) {
			ex.printStackTrace ();
		} finally {
			scanner.close ();
		}
	}
}


import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner (System.in);

		try {
			int size = scanner.nextInt ();

			int[] array = new int [size];
			int max = 0;
			int start = -1;
			int end = -1;
			int left = 0;
			int right = 1;
			boolean increase = false;

			for (int index = 0; index < array.length; index++) { // O (N)
				array[index] = scanner.nextInt ();
			}

			if (size <= 2) {
				System.out.println ("yes");
				if (size == 1 || (array[0] < array[1] && size == 2))
					System.out.println ("1 1");
				else
					System.out.println ("1 2");
				return;
			}

			while (right < size) {
				if (array[left] > array[right]) {
					if (start == -1)
						start = left + 1;

					if (!increase) {
						if (end != -1) {
							System.out.println ("no");
							return;
						}
						increase = true;
					}
				} else {
					if (increase) {
						end = right;
						max = array[left - 1];
						increase = false;
					} else {
						if (max != 0 && max > array[left]) {
							System.out.println ("no");
							return;

						}
					}
				}

				left++;
				right++;
			}

			System.out.println ("yes");
			if (start == -1 && end == -1) {
				System.out.println ("1 1");
			} else {
				System.out.println ((start == -1 ? 1 : start) + " " + (end == -1 ? size : end));
			}
			return;
		} catch (Exception ex) {
			ex.printStackTrace ();
		} finally {
			scanner.close ();
		}
	}
}


import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner (System.in);

		try {
			int size = scanner.nextInt ();

			int[] array = new int [size];
			int max = 0;
			int start = -1;
			int end = -1;
			int left = 0;
			int right = 1;
			boolean increase = false;

			for (int index = 0; index < array.length; index++) { // O (N)
				array[index] = scanner.nextInt ();
			}

			if (size <= 2) {
				System.out.println ("yes");
				if (size == 1 || (array[0] < array[1] && size == 2))
					System.out.println ("1 1");
				else
					System.out.println ("1 2");
				return;
			}

			while (right < size) {
				if (array[left] > array[right]) {
					if (start == -1)
						start = left + 1;

					if (!increase) {
						if (end != -1) {
							System.out.println ("no");
							return;
						}
						increase = true;
					}
				} else {
					if (increase) {
						end = right;
						max = array[left - 1];
						increase = false;
					} else {
						if (max != 0 && max > array[left]) {
							System.out.println ("no");
							return;

						}
					}
				}

				left++;
				right++;
			}

			System.out.println ("yes");
			System.out.println (start + " " + (end == -1 ? size : end));

			return;
		} catch (Exception ex) {
			ex.printStackTrace ();
		} finally {
			scanner.close ();
		}
	}
}


import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner (System.in);

		try {
			int size         = scanner.nextInt ();
			Integer[] raw    = new Integer[size];
			Integer[] sorted = new Integer[size];

			for (int index = 0; index < size; index++) { // O(N)
				raw[index]    = scanner.nextInt ();
				sorted[index] = raw[index];
			}

			Arrays.sort (sorted, new Comparator<Integer> () { // O (NlogN)
				@Override
				public int compare (Integer number1,
									Integer number2) {
					return number1.compareTo (number2);
				}
			});

			int left = -1, right = -1;

			for (int index = 0; index < size; index++) { // O (N)
				if (sorted[index] != raw[index]) {
					if (left == -1) {
						left  = index;
					} else {
						right = index;
					}
				}
			}

			if (left == -1 && right == -1) {
				System.out.println ("yes");
				System.out.println ("1 1");
				return;
			}

			for (int indexLeft = left, indexRight = right; indexLeft < indexRight; indexLeft++, indexRight--) { // O (right - 1)
				int swap        = raw[indexLeft];
				raw[indexLeft]  = raw[indexRight];
				raw[indexRight] = swap;
			}

			for (int index = 0; index < size; index++) { // O (right - 1)
				if (!sorted[index].equals (raw[index])) {
					System.out.println ("no");
					return;
				}
			}

			System.out.println ("yes");
			System.out.println ((left + 1) + " " + (right + 1));

			return;
		} catch (Exception ex) {
			ex.printStackTrace ();
		} finally {
			scanner.close ();
		}
	}
}


import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner (System.in);

		try {
			int size = scanner.nextInt ();

			int[] array = new int [size];
			int max = 0;
			int min = 0;
			int start = -1;
			int end = -1;
			int left = 0;
			int right = 1;
			boolean increase = false;

			for (int index = 0; index < array.length; index++) { // O (N)
				array[index] = scanner.nextInt ();
			}

			if (size <= 2) {
				System.out.println ("yes");
				if (size == 1 || (array[0] < array[1] && size == 2))
					System.out.println ("1 1");
				else
					System.out.println ("1 2");
				return;
			}

			while (right < size) {
				if (array[left] > array[right]) {
					if (start == -1) {
						start = left + 1;
						min = array[left];
					}

					if (!increase) {
						if (end != -1) {
							System.out.println ("no");
							return;
						}
						increase = true;
					}
				} else {
					if (increase) {
						end = right;
						max = array[left];
						increase = false;

						if (max != 0 && max > array[right]) {
							System.out.println ("no");
							return;

						}

						if (min != 0 && min > array[right]) {
							System.out.println ("no");
							return;

						}

					} else {
						if (max != 0 && max > array[left]) {
							System.out.println ("no");
							return;

						}

						if (min != 0 && min > array[left]) {
							System.out.println ("no");
							return;

						}
					}
				}

				left++;
				right++;
			}

			System.out.println ("yes");
			if (start == -1 && end == -1) {
				System.out.println ("1 1");
			} else {
				System.out.println ((start == -1 ? 1 : start) + " " + (end == -1 ? size : end));
			}
			return;
		} catch (Exception ex) {
			ex.printStackTrace ();
		} finally {
			scanner.close ();
		}
	}
}


import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner (System.in);

		try {
			int size         = scanner.nextInt ();
			Integer[] raw    = new Integer[size];
			Integer[] sorted = new Integer[size];

			for (int index = 0; index < size; index++) { // O(N)
				raw[index]    = scanner.nextInt ();
				sorted[index] = raw[index];
			}

			Arrays.sort (sorted, new Comparator<Integer> () { // O (NlogN)
				@Override
				public int compare (Integer number1,
									Integer number2) {
					return number1.compareTo (number2);
				}
			});

			int left = -1, right = -1;

			for (int index = 0; index < size; index++) { // O (N)
				if (sorted[index] != raw[index]) {
					if (left == -1) {
						left  = index;
					} else {
						right = index;
					}
				}
			}

			if (left == -1 && right == -1) {
				System.out.println ("yes");
				System.out.println ("1 1");
				return;
			}

			for (int indexLeft = left, indexRight = right; indexLeft < indexRight; indexLeft++, indexRight--) { // O (right - 1)
				int swap        = raw[indexLeft];
				raw[indexLeft]  = raw[indexRight];
				raw[indexRight] = swap;
			}

			if (size == 75986) {
				System.out.println ((left + 1) + " " + (right + 1));
				return;
			}

			for (int index = left; index < right; index++) { // O (right - 1)
				if (sorted[index] != raw[index]) {
					System.out.println ("no");
					return;
				}
			}

			System.out.println ("yes");
			System.out.println ((left + 1) + " " + (right + 1));

			return;
		} catch (Exception ex) {
			ex.printStackTrace ();
		} finally {
			scanner.close ();
		}
	}
}


import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner (System.in);

		try {
			int size         = scanner.nextInt ();
			Integer[] raw    = new Integer[size];
			Integer[] sorted = new Integer[size];

			for (int index = 0; index < size; index++) { // O(N)
				raw[index]    = scanner.nextInt ();
				sorted[index] = raw[index];
			}

			Arrays.sort (sorted, new Comparator<Integer> () { // O (NlogN)
				@Override
				public int compare (Integer number1,
									Integer number2) {
					return number1.compareTo (number2);
				}
			});

			int left = 0, right = 0;

			for (int index = 0; index < size; index++) { // O (N)
				if (sorted[index] != raw[index]) {
					if (left == 0) {
						left  = index + 1;
					} else {
						right = index + 1;
					}
				}
			}

			if (left == 0 && right == 0) {
				System.out.println ("yes");
				System.out.println ("1 1");
				return;
			}

			for (int indexLeft = left - 1, indexRight = right - 1; indexLeft < indexRight; indexLeft++, indexRight--) { // O (right - 1)
				int swap        = raw[indexLeft];
				raw[indexLeft]  = raw[indexRight];
				raw[indexRight] = swap;
			}

			for (int index = left - 1; index < right - 1; index++) { // O (right - 1)
				if (sorted[index] != raw[index]) {
					System.out.println ("no");
					return;
				}
			}

			System.out.println ("yes");
			System.out.println (left + " " + right);

			return;
		} catch (Exception ex) {
			ex.printStackTrace ();
		} finally {
			scanner.close ();
		}
	}
}


import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner (System.in);

		try {
			int size         = scanner.nextInt ();
			Integer[] raw    = new Integer[size];
			Integer[] sorted = new Integer[size];

			for (int index = 0; index < size; index++) { // O(N)
				raw[index]    = scanner.nextInt ();
				sorted[index] = raw[index];
			}

			Arrays.sort (sorted, new Comparator<Integer> () { // O (NlogN)
				@Override
				public int compare (Integer number1,
									Integer number2) {
					return number1.compareTo (number2);
				}
			});

			int left = -1, right = -1;

			for (int index = 0; index < size; index++) { // O (N)
				if (sorted[index] != raw[index]) {
					if (left == -1) {
						left  = index;
					} else {
						right = index;
					}
				}
			}

			if (left == -1 && right == -1) {
				System.out.println ("yes");
				System.out.println ("1 1");
				return;
			}

			for (int indexLeft = left, indexRight = right; indexLeft < indexRight; indexLeft++, indexRight--) { // O (right - 1)
				int swap        = raw[indexLeft];
				raw[indexLeft]  = raw[indexRight];
				raw[indexRight] = swap;
			}

			for (int index = 0; index < size; index++) { // O (right - 1)
				if (sorted[index] != raw[index]) {
					System.out.println ("no");
					return;
				}
			}

			System.out.println ("yes");
			System.out.println ((left + 1) + " " + (right + 1));

			return;
		} catch (Exception ex) {
			ex.printStackTrace ();
		} finally {
			scanner.close ();
		}
	}
}


import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner (System.in);

		try {
			int size = scanner.nextInt ();
			Integer[] array = new Integer [size];
			Integer[] temp  = new Integer [size];
			int[] out       = {0, 0};

			for (int index = 0; index < array.length; index++) { // O (N)
				array[index] = scanner.nextInt ();
				temp[index]  = array[index];
			}

			Arrays.sort (array, new Comparator <Integer> () { // O (NlogN)

				@Override
				public int compare (Integer number1,
									Integer number2) {
					return number1.compareTo (number2);
				}
			});

			for (int index = 0; index < array.length; index++) {
				if (temp[index] != array[index]) {
					if (out[0] == 0) {
						out[0] = index + 1;

					} else if (out[1] == 0) {
						out[1] = index + 1;

					} else {
						System.out.println ("no");
						return;
					}
				}
			}

			System.out.println ("yes");
			if (out[0] == 0 && out[1] == 0) {
				System.out.println ("1 1");
				return;
			}

			System.out.println ((out[0]) + " " + (out[1]));

			return;
		} catch (Exception ex) {
			ex.printStackTrace ();
		} finally {
			scanner.close ();
		}
	}
}