import java.util.Scanner;

public class Scratch {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n  = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();

        int ans = 1000000000;
        int div1 = n/d;int div2 = n/(e*5);
        for(int i=div1;i>=0;i--){
            int rem = n - (i*d);
            ans = Math.min(ans,rem%(e*5));
        }

        for(int i=div2;i>=0;i--){
            int rem = n - (i*e*5);
            ans = Math.min(ans,rem%(d));
        }

        System.out.println(ans);
    }
}


import java.util.Scanner;

public class Scratch {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n  = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();

        int rem1 = n%d;int rem2 = n%(e*5);
        if(rem1==0 || rem2==0){
            System.out.println(0);
            return;
        }
        int ans = 1000000000;
        int div1 = n/d;int div2 = n/e;
        for(int i=div1;i>=0;i--){
            int rem = n - (i*d);
            ans = Math.min(ans,rem%(e*5));
        }

        for(int i=div2;i>=0;i--){
            int rem = n - (i*e);
            ans = Math.min(ans,rem%(d));
        }

        System.out.println(ans);
    }
}


import java.util.Scanner;

public class Scratch {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n  = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();

        int rem1 = n%d;int rem2 = n%(e*5);
        if(rem1==0 || rem2==0){
            System.out.println(0);
            return;
        }
        System.out.println(Math.min(rem1%(e*5),rem2%d));
    }
}


import java.util.*;

public class Result {

    private static final Scanner scanner = new Scanner(System.in);

    public static void main(String[] args){
        int n=scanner.nextInt();
        int d=scanner.nextInt();
        int e=scanner.nextInt();
        int ans=Integer.MAX_VALUE;
        while (n>=0){
            ans=Math.min(ans,n%d);
            if (ans==0)
                break;
            n=n-5*e;
        }
        System.out.println(ans);
        scanner.close();
    }
}


import java.util.*;

public class Result {

    private static final Scanner scanner = new Scanner(System.in);

    public static void main(String[] args){
        int n=scanner.nextInt();
        int d=scanner.nextInt();
        int e=scanner.nextInt();
        int[] dol=new int[]{1,2,5,10,20,50,100};
        int[] eur=new int[]{5,10,20,50,100,200};

        for (int i=0;i<7;i++)
            dol[i]=dol[i]*d;
        for (int i=0;i<6;i++)
            eur[i]=eur[i]*e;
        int a=n,b=n,i=0;
        while (a>dol[0]||a>eur[0]){
            i=0;
            while (dol[i]<a) i++;
            if (i>0)
                a=a%dol[i-1];
            i=0;
            while (eur[i]<b) i++;
            if (i>0)
                b=b%eur[i-1];
            a=Math.min(a,b);
            b=a;
        }
        System.out.println(a);
        scanner.close();
    }
}


import java.util.*;

public class Result {

    private static final Scanner scanner = new Scanner(System.in);

    public static void main(String[] args){
        int n=scanner.nextInt();
        int d=scanner.nextInt();
        int e=scanner.nextInt();
        int[] dol=new int[]{1,2,5,10,20,50,100};
        int[] eur=new int[]{5,10,20,50,100,200};

        for (int i=0;i<7;i++)
            dol[i]=dol[i]*d;
        for (int i=0;i<6;i++)
            eur[i]=eur[i]*e;
        int a=n,b=n,i=0;
        while (a>=dol[0]||a>=eur[0]){
            i=0;
            while (dol[i]<=a) i++;
            if (i>0)
                a=a%dol[i-1];
            i=0;
            while (eur[i]<=b) i++;
            if (i>0)
                b=b%eur[i-1];
            a=Math.min(a,b);
            b=a;
        }
        System.out.println(a);
        scanner.close();
    }
}


import java.util.*;

public class Result {

    private static final Scanner scanner = new Scanner(System.in);

    public static void main(String[] args){
        int n=scanner.nextInt();
        int d=scanner.nextInt();
        int e=scanner.nextInt();
        int[] dol=new int[]{1,2,5,10,20,50,100};
        int[] eur=new int[]{5,10,20,50,100,200};

        for (int i=0;i<7;i++)
            dol[i]=dol[i]*d;
        for (int i=0;i<6;i++)
            eur[i]=eur[i]*e;
        int a=n,b=n,i=0;
        while (a>=dol[0]||a>=eur[0]){
            i=0;
            while (i<7&&dol[i]<=a) i++;
            if (i>0)
                a=a%dol[i-1];
            i=0;
            while (i<6&&eur[i]<=b) i++;
            if (i>0)
                b=b%eur[i-1];
            a=Math.min(a,b);
            b=a;
        }
        System.out.println(a);
        scanner.close();
    }
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=200010;
int N,M,K,T,a[maxn];
struct trap{
	int L,R,D;
	bool friend operator<(const trap&A,const trap&B){
		return A.D>B.D;
	}
}t[maxn];
int Mx[maxn];
inline bool cmp(int x,int y){
	return x>y;
}
bool check(int x){
	int pr=0,pl=N+1;
	for(int i=1;i<=K;i++){
		if(t[i].D>a[x]){
			pr=max(pr,t[i].R);
			pl=min(pl,t[i].L-1);
		}
	}
	if(!pr)return N+1;
	int tim=2*pr-pl+N+1;
	return tim<=T;
}
int main(){
	//freopen("in","r",stdin);
	M=read(),N=read(),K=read(),T=read();
	for(int i=1;i<=M;i++)a[i]=read();
	for(int i=1;i<=K;i++)
		t[i].L=read(),t[i].R=read(),t[i].D=read();
	sort(a+1,a+1+M,cmp);
	sort(t+1,t+1+K);
	a[0]=1<<30;
	int L=0,R=M,mid,ans;
	while(L+1<R){
		mid=(L+R)/2;
		if(check(mid))
			L=mid;
		else R=mid;
	}
	if(check(R))ans=R;
	else ans=L;

	int cnt=0;
	for(int i=1;i<=M;i++)
		if(a[i]>=t[1].D)
			cnt++;
	if(T>=N+1)
		ans=max(ans,cnt);

	printf("%d\n",ans);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=200010;
int N,M,K,T,a[maxn];
struct trap{
	int L,R,D;
	bool friend operator<(const trap&A,const trap&B){
		return A.D>B.D;
	}
}t[maxn];
int Mx[maxn];
inline bool cmp(int x,int y){
	return x>y;
}
bool check(int x){
	int pos=0;
	for(int i=1;i<=K;i++)
		if(t[i].D>a[x])
			pos=max(pos,t[i].R);
	int tim=2*pos+N+1;
	return tim<=T;
}
int main(){
	//freopen("in","r",stdin);
	M=read(),N=read(),K=read(),T=read();
	for(int i=1;i<=M;i++)a[i]=read();
	for(int i=1;i<=K;i++)
		t[i].L=read(),t[i].R=read(),t[i].D=read();
	sort(a+1,a+1+M,cmp);
	sort(t+1,t+1+K);
	a[0]=1<<30;
	int L=0,R=M,mid,ans;
	while(L+1<R){
		mid=(L+R)/2;
		if(check(mid))
			L=mid;
		else R=mid;
	}
	if(check(R))ans=R;
	else ans=L;

	int cnt=0;
	for(int i=1;i<=M;i++)
		if(a[i]>=t[1].D)
			cnt++;
	if(T>=N+1)
		ans=max(ans,cnt);

	printf("%d\n",ans);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=200010;
int N,M,K,T,a[maxn];
struct trap{
	int L,R,D;
	bool friend operator<(const trap&A,const trap&B){
		return A.D>B.D;
	}
}t[maxn];
inline bool cmp(int x,int y){
	return x>y;
}
multiset<pair<int,int> >s;
bool check(int x){
	s.clear();
	for(int i=1;i<=K;i++)
		if(t[i].D>a[x])
			s.insert(make_pair(t[i].L-1,t[i].R));
	if(s.empty())return 1;
	int tim=0,now=0;
	while(!s.empty()){
		pair<int,int>pii=*s.begin();
		tim+=pii.first-now;
		now=pii.first;
		int Mx=pii.second;
		s.erase(s.begin());
		while(!s.empty()){
			pair<int,int>tmp=*s.begin();
			if(tmp.first<=Mx){
				Mx=tmp.second;
				s.erase(s.begin());
			}
			else break;
		}
		tim+=3*(Mx-now);
		now=Mx;
	}
	tim+=N+1-now;
	return tim<=T;
}
int main(){
	//freopen("in","r",stdin);
	M=read(),N=read(),K=read(),T=read();
	for(int i=1;i<=M;i++)a[i]=read();
	for(int i=1;i<=K;i++)
		t[i].L=read(),t[i].R=read(),t[i].D=read();
	sort(a+1,a+1+M,cmp);
	sort(t+1,t+1+K);
	a[0]=1<<30;
	int L=0,R=M,mid,ans;
	while(L+1<R){
		mid=(L+R)/2;
		if(check(mid))
			L=mid;
		else R=mid;
	}
	if(check(R))ans=R;
	else ans=L;

	int cnt=0;
	for(int i=1;i<=M;i++)
		if(a[i]>=t[1].D)
			cnt++;
	ans=max(ans,cnt);

	printf("%d\n",ans);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=200010;
int M,N,K,T,a[maxn];
struct seg{
	int L,R,d;
	bool friend operator<(const seg&A,const seg&B){
		return A.L<B.L;
	}
}s[maxn],sel[maxn];
inline bool cmp(int A,int B){
	return A>B;
}
bool check(int x){
	int cnt=0;
	for(int i=1;i<=K;i++)
		if(s[i].d>a[x]){
			if(!cnt)sel[++cnt]=s[i];
			else{
				if(sel[cnt].R>=s[i].L)
					sel[cnt].R=s[i].R;
				else sel[++cnt]=s[i];
			}
		}
	int tim=0,now=0;
	for(int i=1;i<=cnt;i++){
		tim+=sel[i].L-now;
		now=sel[i].L;
		tim+=3*(sel[i].R-sel[i].L);
		now=sel[i].R;
	}
	tim+=N+1-now;
	now=N+1;
	return tim<=T;
}
int main(){
	//freopen("in","r",stdin);
	M=read(),N=read(),K=read(),T=read();
	for(int i=1;i<=M;i++)a[i]=read();
	for(int i=1;i<=K;i++)
		s[i].L=read()-1,s[i].R=read(),s[i].d=read();
	sort(a+1,a+1+M,cmp);
	sort(s+1,s+1+K);
	int L=1,R=M,mid,ans=0;
	while(L+1<R){
		mid=(L+R)/2;
		if(check(mid))
			L=mid;
		else R=mid;
	}
	if(check(R))
		ans=R;
	else  if(check(L))
		ans=L;
	printf("%d\n",ans);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=200010;
int N,M,K,T,a[maxn];
struct trap{
	int L,R,D;
	bool friend operator<(const trap&A,const trap&B){
		return A.D>B.D;
	}
}t[maxn];
inline bool cmp(int x,int y){
	return x>y;
}
multiset<pair<int,int> >s;
bool check(int x){
	s.clear();
	for(int i=1;i<=K;i++)
		if(t[i].D>a[x])
			s.insert(make_pair(t[i].L-1,t[i].R));
	int tim=0,now=0;
	while(!s.empty()){
		pair<int,int>pii=*s.begin();
		tim+=pii.first-now;
		now=pii.first;
		int Mx=pii.second;
		s.erase(s.begin());
		while(!s.empty()){
			pair<int,int>tmp=*s.begin();
			if(tmp.first<=Mx){
				Mx=tmp.second;
				s.erase(s.begin());
			}
			else break;
		}
		tim+=3*(Mx-now);
		now=Mx;
	}
	tim+=N+1-now;
	return tim<=T;
}
int main(){
	//freopen("in","r",stdin);
	M=read(),N=read(),K=read(),T=read();
	for(int i=1;i<=M;i++)a[i]=read();
	for(int i=1;i<=K;i++)
		t[i].L=read(),t[i].R=read(),t[i].D=read();
	sort(a+1,a+1+M,cmp);
	sort(t+1,t+1+K);
	a[0]=1<<30;
	int L=0,R=M,mid,ans;
	while(L+1<R){
		mid=(L+R)/2;
		if(check(mid))
			L=mid;
		else R=mid;
	}
	if(check(R))ans=R;
	else ans=L;

	int cnt=0;
	for(int i=1;i<=M;i++)
		if(a[i]>=t[1].D)
			cnt++;
	ans=max(ans,cnt);

	printf("%d\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef int ll;
const ll MAXN=4e5+51;
struct Trap{
	ll l,r,d;
	inline bool operator <(const Trap &rhs)const
	{
		return this->r>rhs.r;
	}
};
Trap p[MAXN];
ll cnt,x,ccnt,t,l,r,mid,res;
ll num[MAXN];
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
}
inline bool check(ll mid)
{
	ll pos=100000000,res=0;
	for(register int i=0;i<ccnt;i++)
	{
		if(p[i].d>num[mid])
		{
			pos=p[i].r;
			break;
		}
	}
	if(pos==100000000)
	{
		pos=0;
	}
	return pos*2+x+1<=t;
}
int main()
{
	cnt=read(),x=read(),ccnt=read(),t=read();
	for(register int i=1;i<=cnt;i++)
	{
		num[i]=read();
	}
	for(register int i=0;i<ccnt;i++)
	{
		p[i].l=read(),p[i].r=read(),p[i].d=read();
	}
	sort(num+1,num+cnt+1,greater<ll>()),sort(p,p+ccnt),l=1,r=cnt;
	for(register int i=cnt;i;i--)
	{
		if(check(i))
		{
			res=i;
			break;
		}
	}
	printf("%d\n",res);
}


#include<bits/stdc++.h>
using namespace std;
typedef int ll;
const ll MAXN=4e5+51;
struct Trap{
	ll l,r,d;
	inline bool operator <(const Trap &rhs)const
	{
		return this->r>rhs.r;
	}
};
Trap p[MAXN];
ll cnt,x,ccnt,t,l,r,mid,res;
ll num[MAXN];
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
}
inline bool check(ll mid)
{
	ll pos=100000000,res=0;
	for(register int i=0;i<ccnt;i++)
	{
		if(p[i].d>num[mid])
		{
			pos=p[i].r;
			break;
		}
	}
	return pos*2+x+1<=t;
}
int main()
{
	cnt=read(),x=read(),ccnt=read(),t=read();
	for(register int i=1;i<=cnt;i++)
	{
		num[i]=read();
	}
	for(register int i=0;i<ccnt;i++)
	{
		p[i].l=read(),p[i].r=read(),p[i].d=read();
	}
	sort(num+1,num+cnt+1,greater<ll>()),sort(p,p+ccnt),l=1,r=cnt;
	while(l<=r)
	{
		mid=(l+r)>>1,check(mid)?l=mid+1,res=mid:r=mid-1;
	}
	printf("%d\n",res);
}


#include<bits/stdc++.h>
using namespace std;
typedef int ll;
const ll MAXN=4e5+51;
struct Trap{
	ll l,r,d;
	inline bool operator <(const Trap &rhs)const
	{
		return this->l<rhs.l;
	}
};
Trap p[MAXN];
ll cnt,x,ccnt,t,l,r,mid,res;
ll num[MAXN];
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
}
inline bool check(ll mid)
{
	ll v=num[cnt-mid+1],r=0,lp=0,rp=0;
	for(register int i=0;i<ccnt;i++)
	{
		if(p[i].d>v)
		{
			if(p[i].l<=rp)
			{
				rp=max(rp,p[i].r);
			}
			else
			{
				r+=(rp-lp)*3+p[i].l-rp-1,lp=p[i].l-1,rp=p[i].r;
			}
		}
	}
	r+=(rp-lp)*3+(x+1-rp);
	return r<=t;
}
int main()
{
	cnt=read(),x=read(),ccnt=read(),t=read();
	for(register int i=1;i<=cnt;i++)
	{
		num[i]=read();
	}
	for(register int i=0;i<ccnt;i++)
	{
		p[i].l=read(),p[i].r=read(),p[i].d=read();
	}
	sort(num+1,num+cnt+1),sort(p,p+ccnt),l=1,r=cnt;
	while(l<=r)
	{
		mid=(l+r)>>1;
		check(mid)?l=mid+1,res=mid:r=mid-1;
	}
	printf("%d\n",res);
}


#include<bits/stdc++.h>
using namespace std;
typedef int ll;
const ll MAXN=3e5+51;
struct Trap{
	ll l,r,d;
	inline bool operator <(const Trap &rhs)const
	{
		return this->r>rhs.r;
	}
};
Trap p[MAXN];
ll cnt,x,ccnt,t,l,r,mid,res;
ll num[MAXN];
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
}
inline bool check(ll mid)
{
	ll pos=100000000,res=0;
	for(register int i=0;i<ccnt;i++)
	{
		if(p[i].d>num[mid])
		{
			pos=p[i].r;
			break;
		}
	}
	return pos*2+x+1<t;
}
int main()
{
	cnt=read(),x=read(),ccnt=read(),t=read();
	for(register int i=1;i<=cnt;i++)
	{
		num[i]=read();
	}
	for(register int i=0;i<ccnt;i++)
	{
		p[i].l=read(),p[i].r=read(),p[i].d=read();
	}
	sort(num+1,num+cnt+1,greater<ll>()),sort(p,p+ccnt),l=1,r=cnt;
	while(l<r)
	{
		mid=(l+r)>>1,check(mid)?l=mid+1,res=mid:r=mid-1;
	}
	printf("%d\n",res);
}


#include<bits/stdc++.h>
using namespace std;
typedef int ll;
const ll MAXN=1e5+51;
struct Trap{
	ll l,r,d;
	inline bool operator <(const Trap &rhs)const
	{
		return this->r>rhs.r;
	}
};
Trap p[MAXN];
ll cnt,x,ccnt,t,l,r,mid,res;
ll num[MAXN];
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
}
inline bool check(ll mid)
{
	ll pos=100000000,res=0;
	for(register int i=0;i<ccnt;i++)
	{
		if(p[i].d>num[mid])
		{
			pos=p[i].r;
			break;
		}
	}
	return pos*2+x+1<=t;
}
int main()
{
	cnt=read(),x=read(),ccnt=read(),t=read();
	for(register int i=1;i<=cnt;i++)
	{
		num[i]=read();
	}
	for(register int i=0;i<ccnt;i++)
	{
		p[i].l=read(),p[i].r=read(),p[i].d=read();
	}
	sort(num+1,num+cnt+1,greater<ll>()),sort(p,p+ccnt),l=1,r=cnt;
	while(l<r)
	{
		mid=(l+r)>>1,check(mid)?l=mid+1,res=mid:r=mid-1;
	}
	printf("%d\n",res);
}


#include<bits/stdc++.h>
using namespace std;
typedef int ll;
const ll MAXN=4e5+51;
struct Trap{
	ll l,r,d;
	inline bool operator <(const Trap &rhs)const
	{
		return this->r>rhs.r;
	}
};
Trap p[MAXN];
ll cnt,x,ccnt,t,l,r,mid,res;
ll num[MAXN];
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
}
inline bool check(ll mid)
{
	ll pos=100000000,res=0;
	for(register int i=0;i<ccnt;i++)
	{
		if(p[i].d>num[mid])
		{
			pos=p[i].r;
			break;
		}
	}
	if(pos==100000000)
	{
		pos=0;
	}
	return pos*2+x+1<=t;
}
int main()
{
	cnt=read(),x=read(),ccnt=read(),t=read();
	for(register int i=1;i<=cnt;i++)
	{
		num[i]=read();
	}
	for(register int i=0;i<ccnt;i++)
	{
		p[i].l=read(),p[i].r=read(),p[i].d=read();
	}
	sort(num+1,num+cnt+1,greater<ll>()),sort(p,p+ccnt),l=1,r=cnt;
	while(l<=r)
	{
		mid=(l+r)>>1,check(mid)?l=mid+1,res=mid:r=mid-1;
	}
	printf("%d\n",res);
}


#include<bits/stdc++.h>
using namespace std;
int a[200010],l[200010],r[200010],d[200010];
int n,m,k,t;
int solve(int x){
	int ans=n+1;
    vector<pair<int,int> > s;
    for(int i=0;i<k;i++){
    	if(d[i]>x){
    		s.push_back(make_pair(l[i],r[i]));
    	}
    }
    sort(s.begin(),s.end());
    reverse(s.begin(),s.end());
    int right;
    int left;
    while(!s.empty()){
    	left=s.back().first;
    	right=s.back().second;
    	while(!s.empty()&&s.back().first<=right){
    		right=max(right,s.back().second);
    		s.pop_back();
    	}
        ans+=2*(right-left+1);
    }
    return ans;

}
int main(){
	cin>>m>>n>>k>>t;
	for (int i = 0; i <m; ++i)
	{
		cin>>a[i];
		/* code */
	}
	sort(a,a+m);
	for(int i=0;i<k;i++){
		cin>>l[i]>>r[i]>>d[i];
	}
	int ans=m;
	int li=0;int ri=200010;
	int mid=(li+ri)/2;
	while(li<ri){
		mid=(li+ri)/2;
		if(solve(mid)<=t){
			ri=mid;
			ans=mid;
		}
		else{
			li=mid+1;
		}
	}
	int res=0;
	for(int i=0;i<m;i++){
		if(a[i]>=ans) res++;

	}
	cout<<res<<endl;

}


#include<bits/stdc++.h>
using namespace std;
int a[200010],l[200010],r[200010],d[200010];
int n,m,k,t;
int solve(int x){
	int ans=n+1;
    vector<pair<int,int> > s;
    for(int i=0;i<k;i++){
    	if(d[i]>x){
    		s.push_back(make_pair(l[i],r[i]));
    	}
    }
    sort(s.begin(),s.end());
    reverse(s.begin(),s.end());
    int mx=0;
    while(!s.empty()){
       if(s.back().second<=mx){
           s.pop_back();
			continue;
        }

			mx=max(mx,s.back().first-1);
			ans+=(s.back().second-mx)*2;
			mx=s.back().second;
			s.pop_back();
    }
    return ans;

}
int main(){
	cin>>m>>n>>k>>t;
	for (int i = 0; i <m; ++i)
	{
		cin>>a[i];
		/* code */
	}
	sort(a,a+m);
	for(int i=0;i<k;i++){
		cin>>l[i]>>r[i]>>d[i];
	}
	int ans=m;
	int li=0;int ri=m-1;
	int mid=(li+ri)/2;
	while(li<ri){
		mid=(li+ri)/2;
		if(solve(a[mid])<=t){
			ri=mid;
			ans=mid;
		}
		else{
			li=mid+1;
		}
	}
	cout<<m-ans;

}


#include<bits/stdc++.h>
using namespace std;
int a[200010],l[200010],r[200010],d[200010];
int n,m,k,t;
int solve(int x){
	int ans=n+1;
    vector<pair<int,int> > s;
    for(int i=0;i<k;i++){
    	if(d[i]>x){
    		s.push_back(make_pair(l[i],r[i]));
    	}
    }
    sort(s.begin(),s.end());
    reverse(s.begin(),s.end());
    int right=0;
    int left=0;
    while(!s.empty()){
        if(s.back().second<=right) {
            s.pop_back();
            continue;
        }
        left=max(s.back().first-1, right);
        right=s.back().second;
        ans+=2*(right-left);
        s.pop_back();

    }
    return ans;

}
int main(){
	cin>>m>>n>>k>>t;
	for (int i = 0; i <m; ++i)
	{
		cin>>a[i];
		/* code */
	}
	sort(a,a+m);
	for(int i=0;i<k;i++){
		cin>>l[i]>>r[i]>>d[i];
	}
	int ans=m;
	int li=0;int ri=m-1;
	int mid=(li+ri)/2;
	while(li<ri){
		mid=(li+ri)/2;
		if(solve(a[mid])<=t){
			ri=mid;
			ans=mid;
		}
		else{
			li=mid+1;
		}
	}
	cout<<m-ans;

}


#include<bits/stdc++.h>
using namespace std;
int a[200010],l[200010],r[200010],d[200010];
int n,m,k,t;
int solve(int x){
	int ans=n+1;
    vector<pair<int,int> > s;
    for(int i=0;i<k;i++){
    	if(d[i]>x){
    		s.push_back(make_pair(l[i],r[i]));
    	}
    }
    sort(s.begin(),s.end());
    reverse(s.begin(),s.end());
    int right;
    int left;
    while(!s.empty()){
    	left=s.back().first;
    	right=s.back().second;
    	while(s.back().first<=right&&!s.empty()){
    		right=max(right,s.back().second);
    		s.pop_back();
    	}
        ans+=2*(right-left+1);
    }
    return ans;

}
int main(){
	cin>>m>>n>>k>>t;
	for (int i = 0; i <m; ++i)
	{
		cin>>a[i];
		/* code */
	}
	sort(a,a+m);
	for(int i=0;i<k;i++){
		cin>>l[i]>>r[i]>>d[i];
	}
	int ans=m;
	int li=0;int ri=m-1;
	int mid=(li+ri)/2;
	while(li<ri){
		mid=(li+ri)/2;
		if(solve(a[mid])<=t){
			ri=mid;
			ans=mid;
		}
		else{
			li=mid+1;
		}
	}
	cout<<m-ans;

}


#include<bits/stdc++.h>
using namespace std;
int a[200010],l[200010],r[200010],d[200010];
int n,m,k,t;
int solve(int x){
	int ans=n+1;
    vector<pair<int,int> > s;
    for(int i=0;i<k;i++){
    	if(d[i]>x){
    		s.push_back(make_pair(l[i],r[i]));
    	}
    }
    sort(s.begin(),s.end());
    reverse(s.begin(),s.end());
    int right;
    int left;
    while(!s.empty()){
    	left=s.back().first;
    	right=s.back().second;
    	while(!s.empty()&&s.back().first<=right){
    		right=max(right,s.back().second);
    		s.pop_back();
    	}
        ans+=2*(right-left+1);
    }
    return ans;

}
int main(){
	cin>>m>>n>>k>>t;
	for (int i = 0; i <m; ++i)
	{
		cin>>a[i];
		/* code */
	}
	sort(a,a+m);
	for(int i=0;i<k;i++){
		cin>>l[i]>>r[i]>>d[i];
	}
	int ans;
	int li=0;int ri=m;
	int mid=(li+ri)/2;
	while(li<ri){
		mid=(li+ri)/2;
		if(solve(a[mid])<=t){
			ri=mid;
			ans=mid;
		}
		else{
			li=mid+1;
		}
	}
	cout<<m-ans;

}


#include<bits/stdc++.h>
using namespace std;
int a[200010],l[200010],r[200010],d[200010];
int n,m,k,t;
int solve(int x){
	int ans=n+1;
    vector<pair<int,int> > s;
    for(int i=0;i<k;i++){
    	if(d[i]>x){
    		s.push_back(make_pair(l[i],r[i]));
    	}
    }
    sort(s.begin(),s.end());
    reverse(s.begin(),s.end());
    int right;
    int left;
    while(!s.empty()){
    	left=s.back().first;
    	right=s.back().second;
    	while(!s.empty()&&s.back().first<=right){
    		right=max(right,s.back().second);
    		s.pop_back();
    	}
        ans+=2*(right-left+1);
    }
    return ans;

}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	cin>>m>>n>>k>>t;
	for (int i = 0; i <m; ++i)
	{
		cin>>a[i];
		/* code */
	}
	sort(a,a+m);
	for(int i=0;i<k;i++){
		cin>>l[i]>>r[i]>>d[i];
	}
	int ans=m;
	int li=0;int ri=200010;
	int mid=(li+ri)/2;
	while(li<ri){
		mid=(li+ri)/2;
		if(solve(mid)<=t){
			ri=mid;
			ans=mid;
		}
		else{
			li=mid+1;
		}
	}
	int res=0;
	for(int i=0;i<m;i++){
		if(a[i]>=ans) res++;

	}
	cout<<res<<endl;

}


#include<bits/stdc++.h>
using namespace std;
int a[200010],l[200010],r[200010],d[200010];
int n,m,k,t;
int solve(int x){
	int ans=n+1;
    vector<pair<int,int> > s;
    for(int i=0;i<k;i++){
    	if(d[i]>x){
    		s.push_back(make_pair(l[i],r[i]));
    	}
    }
    sort(s.begin(),s.end());
    reverse(s.begin(),s.end());
    int mx=0;
    while(!s.empty()){
       if(s.back().second<=mx){
           s.pop_back();
			continue;
        }
			mx=max(mx,s.back().first-1);
			ans+=(s.back().second-mx)*2;
			mx=s.back().second;
			s.pop_back();
    }
    return ans;

}
int main(){
	cin>>m>>n>>k>>t;
	for (int i = 0; i <m; ++i)
	{
		cin>>a[i];
		/* code */
	}
	sort(a,a+m);
	for(int i=0;i<k;i++){
		cin>>l[i]>>r[i]>>d[i];
	}
	int ans=m;
	int li=0;int ri=200010;
	int mid=(li+ri)/2;
	while(li<ri){
		mid=(li+ri)/2;
		if(solve(mid)<=t){
			ri=mid;
			ans=mid;
		}
		else{
			li=mid+1;
		}
	}
	int res=0;
	for(int i=0;i<m;i++){
		if(a[i]>=ans) res++;
	}
	cout<<res<<endl;

}


#include<bits/stdc++.h>
using namespace std;
int a[200010],l[200010],r[200010],d[200010];
int n,m,k,t;
int solve(int x){
	int ans=n+1;
    vector<pair<int,int> > s;
    for(int i=0;i<k;i++){
    	if(d[i]>x){
    		s.push_back(make_pair(l[i],r[i]));
    	}
    }
    sort(s.begin(),s.end());
    reverse(s.begin(),s.end());
    int mx=0;
    while(!s.empty()){
       if(s.back().second<=mx){
           s.pop_back();
			continue;
        }

			mx=max(mx,s.back().second-1);
			ans+=(s.back().second-mx)*2;
			mx=s.back().second;
			s.pop_back();
    }
    return ans;

}
int main(){
	cin>>m>>n>>k>>t;
	for (int i = 0; i <m; ++i)
	{
		cin>>a[i];
		/* code */
	}
	sort(a,a+m);
	for(int i=0;i<k;i++){
		cin>>l[i]>>r[i]>>d[i];
	}
	int ans=m;
	int li=0;int ri=m-1;
	int mid=(li+ri)/2;
	while(li<ri){
		mid=(li+ri)/2;
		if(solve(a[mid])<=t){
			ri=mid;
			ans=mid;
		}
		else{
			li=mid+1;
		}
	}
	cout<<m-ans;

}


#include<bits/stdc++.h>
using namespace std;
int a[200010],l[200010],r[200010],d[200010];
int n,m,k,t;
int solve(int x){
	int ans=n+1;
    vector<pair<int,int> > s;
    for(int i=0;i<k;i++){
    	if(d[i]>x){
    		s.push_back(make_pair(l[i],r[i]));
    	}
    }
    sort(s.begin(),s.end());
    reverse(s.begin(),s.end());
    int right;
    int left;
    while(!s.empty()){
    	left=s.back().first;
    	right=s.back().second;
    	while(!s.empty()&&s.back().first<=right){
    		right=max(right,s.back().second);
    		s.pop_back();
    	}
        ans+=2*(right-left+1);
    }
    return ans;

}
int main(){
	cin>>m>>n>>k>>t;
	for (int i = 0; i <m; ++i)
	{
		cin>>a[i];
		/* code */
	}
	sort(a,a+m);
	for(int i=0;i<k;i++){
		cin>>l[i]>>r[i]>>d[i];
	}
	int ans=m;
	int li=0;int ri=m-1;
	int mid=(li+ri)/2;
	while(li<ri){
		mid=(li+ri)/2;
		if(solve(a[mid])<=t){
			ri=mid;
			ans=mid;
		}
		else{
			li=mid+1;
		}
	}
	cout<<m-ans;

}


#include<iostream>
#include<iomanip>
#include<fstream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdio>
#include<map>
#include<vector>
#include<ostream>
#include<istream>
typedef long long ll;
using namespace std;
#define mod 1e9+7
#define PI acos(-1.0)
const ll maxn=2*1e5;
const int mx=(1<<20)+99;
ll n,m,k,ti,a[maxn+10],aans,ans;
struct trap{
    ll pos,dispos,atk;
} b[maxn+10];
bool cmp(trap a,trap b){
    return a.dispos<b.dispos;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
//    int t;
//    cin>>t;
//    for(int o=1;o<=t;o++)
//    {
        cin>>m>>n>>k>>ti;
        if(ti<n+1) { cout<<"0"<<endl; return 0; }
        for(int i=1;i<=m;i++)
        cin>>a[i];
        sort(a+1,a+m+1);
        for(int i=1;i<=k;i++)
        {
            cin>>b[i].pos>>b[i].dispos>>b[i].atk;
        }
        sort(b+1,b+1+k,cmp);
        aans=(ti-n-1)/2; ans=-1;
        if(aans>=n) { cout<<m<<endl; return 0; }
        for(int i=1;i<=k;i++)
        {
            if(b[i].atk<=b[aans].atk) continue;
            ans=max(ans,b[i].atk);
        }
        //cout<<aans<<" "<<ans<<endl;
        for(int i=1;i<=m;i++)
        {
            if(a[i]>=ans)
            { cout<<m-i+1<<endl; break; }
            if(i==m) cout<<"0"<<endl;
        }
//    }
    return 0;
}
/*
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}

ll cal(ll a,ll b)//a^b
{
    ll ans=1;
    while(b)
    {
        if(b%2)
        ans=ans*a%mod;
        b/=2;
        a=a*a%mod;
    }
    return ans;
}

ll exgcd(ll a,ll b,ll &x,ll &y)
{
    if(!b)
    {
        x=1,y=0;
        return a;
    }
    ll d=egcd(b,a%b,x,y);
    ll x1=x;
    x=y;
    y=x1-(a/b)*y;
    return d;
}
*/


#include<iostream>
#include<iomanip>
#include<fstream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdio>
#include<map>
#include<vector>
#include<ostream>
#include<istream>
typedef long long ll;
using namespace std;
#define mod 1e9+7
#define PI acos(-1.0)
const ll maxn=2*1e5;
const int mx=(1<<20)+99;
ll n,m,k,ti,a[maxn+10],aans,ans;
struct trap{
    ll pos,dispos,atk;
} b[maxn+10];
bool cmp(trap a,trap b){
    return a.dispos<b.dispos;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
//    int t;
//    cin>>t;
//    for(int o=1;o<=t;o++)
//    {
        cin>>m>>n>>k>>ti;
        for(int i=1;i<=m;i++)
        cin>>a[i];
        sort(a+1,a+m+1);
        for(int i=1;i<=k;i++)
        {
            cin>>b[i].pos>>b[i].dispos>>b[i].atk;
        }
        sort(b+1,b+1+k,cmp);
        aans=(ti-n-1)/2; ans=-1;
        if(ti<n+1) { cout<<"0"<<endl; return 0; }
        for(int i=1;i<=k;i++)
        {
            if(i<=aans) continue;
            ans=max(ans,b[i].atk);
        }
        cout<<aans<<" "<<ans<<endl;
        for(int i=1;i<=m;i++)
        if(a[i]>=ans) { cout<<m-i+1<<endl; break; }
//    }
    return 0;
}
/*
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}

ll cal(ll a,ll b)//a^b
{
    ll ans=1;
    while(b)
    {
        if(b%2)
        ans=ans*a%mod;
        b/=2;
        a=a*a%mod;
    }
    return ans;
}

ll exgcd(ll a,ll b,ll &x,ll &y)
{
    if(!b)
    {
        x=1,y=0;
        return a;
    }
    ll d=egcd(b,a%b,x,y);
    ll x1=x;
    x=y;
    y=x1-(a/b)*y;
    return d;
}
*/


#include<iostream>
#include<iomanip>
#include<fstream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdio>
#include<map>
#include<vector>
#include<ostream>
#include<istream>
typedef long long ll;
using namespace std;
#define mod 1e9+7
#define PI acos(-1.0)
const ll maxn=2*1e5;
const int mx=(1<<20)+99;
ll n,m,k,ti,a[maxn+10],aans,ans;
struct trap{
    ll pos,dispos,atk;
} b[maxn+10];
bool cmp(trap a,trap b){
    return a.dispos<b.dispos;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
//    int t;
//    cin>>t;
//    for(int o=1;o<=t;o++)
//    {
        cin>>m>>n>>k>>ti;
        if(ti<n+1) { cout<<"0"<<endl; return 0; }
        for(int i=1;i<=m;i++)
        cin>>a[i];
        sort(a+1,a+m+1);
        for(int i=1;i<=k;i++)
        {
            cin>>b[i].pos>>b[i].dispos>>b[i].atk;
        }
        sort(b+1,b+1+k,cmp);
        aans=(ti-n-1)/2; ans=-1;
        if(aans>=n) { cout<<m<<endl; return 0; }
        for(int i=1;i<=k;i++)
        {
            //if(i<=aans) continue;
            if(b[i].dispos<=aans) continue;
            ans=max(ans,b[i].atk);
        }
        //cout<<aans<<" "<<ans<<endl;
        for(int i=1;i<=m;i++)
        {
            if(a[i]>=ans)
            { cout<<m-i+1<<endl; break; }
            if(i==m) cout<<"0"<<endl;
        }
//    }
    return 0;
}
/*
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}

ll cal(ll a,ll b)//a^b
{
    ll ans=1;
    while(b)
    {
        if(b%2)
        ans=ans*a%mod;
        b/=2;
        a=a*a%mod;
    }
    return ans;
}

ll exgcd(ll a,ll b,ll &x,ll &y)
{
    if(!b)
    {
        x=1,y=0;
        return a;
    }
    ll d=egcd(b,a%b,x,y);
    ll x1=x;
    x=y;
    y=x1-(a/b)*y;
    return d;
}
*/


#include<iostream>
#include<iomanip>
#include<fstream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdio>
#include<map>
#include<vector>
#include<ostream>
#include<istream>
typedef long long ll;
using namespace std;
#define mod 1e9+7
#define PI acos(-1.0)
const ll maxn=2*1e5;
const int mx=(1<<20)+99;
ll n,m,k,ti,a[maxn+10],aans,ans;
struct trap{
    ll pos,dispos,atk;
} b[maxn+10];
bool cmp(trap a,trap b){
    return a.dispos<b.dispos;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
//    int t;
//    cin>>t;
//    for(int o=1;o<=t;o++)
//    {
        cin>>m>>n>>k>>ti;
        for(int i=1;i<=m;i++)
        cin>>a[i];
        sort(a+1,a+m+1);
        for(int i=1;i<=k;i++)
        {
            cin>>b[i].pos>>b[i].dispos>>b[i].atk;
        }
        sort(b+1,b+1+k,cmp);
        aans=(ti-n-1)/2; ans=-1;
        if(aans>=n) { cout<<m<<endl; return 0; }
        if(ti<n+1) { cout<<"0"<<endl; return 0; }
        for(int i=1;i<=k;i++)
        {
            if(i<=aans) continue;
            ans=max(ans,b[i].atk);
        }
        //cout<<aans<<" "<<ans<<endl;
        for(int i=1;i<=m;i++)
        {
            if(a[i]>=ans)
            { cout<<m-i+1<<endl; break; }
            if(i==m) cout<"0"<<endl;
        }
//    }
    return 0;
}
/*
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}

ll cal(ll a,ll b)//a^b
{
    ll ans=1;
    while(b)
    {
        if(b%2)
        ans=ans*a%mod;
        b/=2;
        a=a*a%mod;
    }
    return ans;
}

ll exgcd(ll a,ll b,ll &x,ll &y)
{
    if(!b)
    {
        x=1,y=0;
        return a;
    }
    ll d=egcd(b,a%b,x,y);
    ll x1=x;
    x=y;
    y=x1-(a/b)*y;
    return d;
}
*/


#include<iostream>
#include<iomanip>
#include<fstream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdio>
#include<map>
#include<vector>
#include<ostream>
#include<istream>
typedef long long ll;
using namespace std;
#define mod 1e9+7
#define PI acos(-1.0)
const ll maxn=2*1e5;
const int mx=(1<<20)+99;
ll n,m,k,ti,a[maxn+10],aans,ans;
struct trap{
    ll pos,dispos,atk;
} b[maxn+10];
bool cmp(trap a,trap b){
    return a.dispos<b.dispos;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
//    int t;
//    cin>>t;
//    for(int o=1;o<=t;o++)
//    {
        cin>>m>>n>>k>>ti;
        for(int i=1;i<=m;i++)
        cin>>a[i];
        sort(a+1,a+m+1);
        for(int i=1;i<=k;i++)
        {
            cin>>b[i].pos>>b[i].dispos>>b[i].atk;
        }
        sort(b+1,b+1+k,cmp);
        aans=(ti-n-1)/2; ans=-1;
        if(aans>=n) { cout<<m<<endl; return 0; }
        if(ti<n+1) { cout<<"0"<<endl; return 0; }
        for(int i=1;i<=k;i++)
        {
            if(i<=aans) continue;
            ans=max(ans,b[i].atk);
        }
        //cout<<aans<<" "<<ans<<endl;
        for(int i=1;i<=m;i++)
        {
            if(a[i]>=ans)
            { cout<<m-i+1<<endl; break; }
            if(i==m) cout<<"0"<<endl;
        }
//    }
    return 0;
}
/*
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}

ll cal(ll a,ll b)//a^b
{
    ll ans=1;
    while(b)
    {
        if(b%2)
        ans=ans*a%mod;
        b/=2;
        a=a*a%mod;
    }
    return ans;
}

ll exgcd(ll a,ll b,ll &x,ll &y)
{
    if(!b)
    {
        x=1,y=0;
        return a;
    }
    ll d=egcd(b,a%b,x,y);
    ll x1=x;
    x=y;
    y=x1-(a/b)*y;
    return d;
}
*/


#include<iostream>
#include<iomanip>
#include<fstream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdio>
#include<map>
#include<vector>
#include<ostream>
#include<istream>
typedef long long ll;
using namespace std;
#define mod 1e9+7
#define PI acos(-1.0)
const ll maxn=2*1e5;
const int mx=(1<<20)+99;
ll n,m,k,ti,a[maxn+10],aans,ans;
struct trap{
    ll pos,dispos,atk;
} b[maxn+10];
bool cmp(trap a,trap b){
    return a.dispos<b.dispos;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
//    int t;
//    cin>>t;
//    for(int o=1;o<=t;o++)
//    {
        cin>>m>>n>>k>>ti;
        for(int i=1;i<=m;i++)
        cin>>a[i];
        sort(a+1,a+m+1);
        for(int i=1;i<=k;i++)
        {
            cin>>b[i].pos>>b[i].dispos>>b[i].atk;
        }
        sort(b+1,b+1+k,cmp);
        aans=(ti-n-1)/2; ans=-1;
        if(aans>n) aans=n;
        if(ti<n+1) { cout<<"0"<<endl; return 0; }
        for(int i=1;i<=k;i++)
        {
            if(i<=aans) continue;
            ans=max(ans,b[i].atk);
        }
        //cout<<aans<<" "<<ans<<endl;
        for(int i=1;i<=m;i++)
        {
            if(a[i]>=ans)
            { cout<<m-i+1<<endl; break; }
            if(i==m) cout<<m<<endl;
        }
//    }
    return 0;
}
/*
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}

ll cal(ll a,ll b)//a^b
{
    ll ans=1;
    while(b)
    {
        if(b%2)
        ans=ans*a%mod;
        b/=2;
        a=a*a%mod;
    }
    return ans;
}

ll exgcd(ll a,ll b,ll &x,ll &y)
{
    if(!b)
    {
        x=1,y=0;
        return a;
    }
    ll d=egcd(b,a%b,x,y);
    ll x1=x;
    x=y;
    y=x1-(a/b)*y;
    return d;
}
*/


#include<iostream>
#include<iomanip>
#include<fstream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdio>
#include<map>
#include<vector>
#include<ostream>
#include<istream>
typedef long long ll;
using namespace std;
#define mod 1e9+7
#define PI acos(-1.0)
const ll maxn=2*1e5;
const int mx=(1<<20)+99;
ll n,m,k,ti,a[maxn+10],aans,ans;
struct trap{
    ll pos,dispos,atk;
} b[maxn+10];
bool cmp(trap a,trap b){
    return a.dispos<b.dispos;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
//    int t;
//    cin>>t;
//    for(int o=1;o<=t;o++)
//    {
        cin>>m>>n>>k>>ti;
        for(int i=1;i<=m;i++)
        cin>>a[i];
        sort(a+1,a+m+1);
        for(int i=1;i<=k;i++)
        {
            cin>>b[i].pos>>b[i].dispos>>b[i].atk;
        }
        sort(b+1,b+1+k,cmp);
        aans=(ti-n-1)/2; ans=-1;
        if(ti<n+1) { cout<<"0"<<endl; return 0; }
        for(int i=1;i<=k;i++)
        {
            if(i<=aans) continue;
            ans=max(ans,b[i].atk);
        }
        //cout<<aans<<" "<<ans<<endl;
        for(int i=1;i<=m;i++)
        if(a[i]>=ans) { cout<<m-i+1<<endl; break; }
//    }
    return 0;
}
/*
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}

ll cal(ll a,ll b)//a^b
{
    ll ans=1;
    while(b)
    {
        if(b%2)
        ans=ans*a%mod;
        b/=2;
        a=a*a%mod;
    }
    return ans;
}

ll exgcd(ll a,ll b,ll &x,ll &y)
{
    if(!b)
    {
        x=1,y=0;
        return a;
    }
    ll d=egcd(b,a%b,x,y);
    ll x1=x;
    x=y;
    y=x1-(a/b)*y;
    return d;
}
*/


#include<iostream>
#include<iomanip>
#include<fstream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdio>
#include<map>
#include<vector>
#include<ostream>
#include<istream>
typedef long long ll;
using namespace std;
#define mod 1e9+7
#define PI acos(-1.0)
const ll maxn=200000;
const int mx=maxn+10;
struct node {
	int l,r;
	int d;

} s[mx];
int sum[mx];
int a[mx];
int n,m,K,t;
bool check(int mid) {
	for (int i=0;i<=n;i++) sum[i] = 0;
	for (int i=1;i<=K;i++) {
		if (s[i].d > mid) {
			sum[s[i].l]++;
			sum[s[i].r+1]--;
		}
	}
	int len = 0;
	for (int i=1;i<=n;i++) {
		sum[i] += sum[i-1];
		len += (sum[i] != 0);
	}
	int ret = len*3 + (n+1-len);
	return ret <= t;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    /*int t;
    cin>>t;
    for(int o=1;o<=t;o++)
    {

    }*/
    scanf("%d%d%d%d",&m,&n,&K,&t);
	int l = 0,r = m;
	for (int i=1;i<=m;i++)
		scanf("%d",a+i);
	sort(a+1,a+1+m,greater<int>());
	for (int i=1;i<=K;i++) {
		scanf("%d%d%d",&s[i].l,&s[i].r,&s[i].d);
	}
	a[0] = 1e6;
	while (l < r) {
		int mid = l+r+1>>1;
		if (check(a[mid]))
			l = mid;
		else
			r = mid - 1;
	}
	printf("%d\n",l);
}
/*
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}

ll cal(ll a,ll b)//快速幂求a^b
{
    ll ans=1;
    while(b)
    {
        if(b%2)
        ans=ans*a%mod;
        b/=2;
        a=a*a%mod;
    }
    return ans;
}

ll exgcd(ll a,ll b,ll &x,ll &y)
{
    if(!b)
    {
        x=1,y=0;
        return a;
    }
    ll d=egcd(b,a%b,x,y);
    ll x1=x;
    x=y;
    y=x1-(a/b)*y;
    return d;
}
*/


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

struct Trap {
    int l, r, d;

    bool operator < (const Trap &other) const {
        if (d == other.d)
            return l < other.l;
        return d < other.d;
    }
};

int a[200000];
Trap traps[200000];

int BIT[200001] = {};

int getMax(int index) {
    int ret = 0;
    while (index > 0) {
        ret = max(ret, BIT[index]);
        index -= index & (-index);
    }
    return ret;
}

void update(int index, int val) {
    while (index <= 200000) {
        BIT[index] = max(BIT[index], val);
        index += index & (-index);
    }
}

int BIT2[200001];

int getMin(int index) {
    int ret = INT_MAX;
    while (index > 0) {
        ret = min(ret, BIT2[index]);
        index -= index & (-index);
    }
    return ret;
}

void update2(int index, int val) {
    while (index <= 200000) {
        BIT2[index] = min(BIT2[index], val);
        index += index & (-index);
    }
}

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

    memset(BIT2, 127, sizeof(BIT2));

    int m, n, k, t;
    cin >> m >> n >> k >> t;
    for (int i=0; i<m; i++)
        cin >> a[i];
    for (int i=0; i<k; i++) {
        cin >> traps[i].l >> traps[i].r >> traps[i].d;
        update(200001 - traps[i].d, traps[i].r);
        update2(200001 - traps[i].d, traps[i].l);
    }

    sort(a, a + m, greater<int>());
    sort(traps, traps + k);
    int l = 0, r = m;
    while (l < r) {
        int mid = (l + r) / 2, i = 0;

        int firstL = getMin(200001 - (a[mid] + 1));
        int squad = firstL - 1, you = firstL - 1, tt = t - firstL + 1;

        int lastR = getMax(200001 - (a[mid] + 1));
        long long timeConsumed = 2 * (lastR - you) + n + 1 - squad;

        if (timeConsumed < 0 || timeConsumed > tt)
            r = mid;
        else
            l = mid + 1;
    }

    cout << l << "\n";

    return 0;
}


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

//int BIT[200001] = {};
//
//int getMax(int index) {
//    int ret = 0;
//    while (index > 0) {
//        ret = max(ret, BIT[index]);
//        index -= index & (-index);
//    }
//    return ret;
//}
//
//void update(int index, int val) {
//    while (index <= 200000) {
//        BIT[index] = max(BIT[index], val);
//        index += index & (-index);
//    }
//}
//
//int BIT2[200001];
//
//int getMin(int index) {
//    int ret = 1e9;
//    while (index > 0) {
//        ret = min(ret, BIT2[index]);
//        index -= index & (-index);
//    }
//    return ret;
//}
//
//void update2(int index, int val) {
//    while (index <= 200000) {
//        BIT2[index] = min(BIT2[index], val);
//        index += index & (-index);
//    }
//}

struct Trap {
    int l, r, d;
};

int a[200000];
Trap traps[200000];

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

    //memset(BIT2, 127, sizeof(BIT2));

    int m, n, k, t;
    cin >> m >> n >> k >> t;
    for (int i=0; i<m; i++)
        cin >> a[i];
    for (int i=0; i<k; i++)
        cin >> traps[i].l >> traps[i].r >> traps[i].d;

    sort(a, a + m, greater<int>());
    int l = 0, r = m;
    while (l < r) {
        int mid = (l + r) / 2;

        int L = INT_MAX, R = 0;
        for (int i=0; i<k; i++)
            if (traps[i].d > a[mid])
                L = min(L, traps[i].l), R = max(R, traps[i].r);

        int timeConsumed = n + 1 + (R == 0 ? 0 : 2 * (R - L + 1));

        if (timeConsumed > t)
            r = mid;
        else
            l = mid + 1;
    }

    cout << l << "\n";

    return 0;
}


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

int BIT[200001] = {};

int getMax(int index) {
    int ret = 0;
    while (index > 0) {
        ret = max(ret, BIT[index]);
        index -= index & (-index);
    }
    return ret;
}

void update(int index, int val) {
    while (index <= 200000) {
        BIT[index] = max(BIT[index], val);
        index += index & (-index);
    }
}

int BIT2[200001];

int getMin(int index) {
    int ret = 1e9;
    while (index > 0) {
        ret = min(ret, BIT2[index]);
        index -= index & (-index);
    }
    return ret;
}

void update2(int index, int val) {
    while (index <= 200000) {
        BIT2[index] = min(BIT2[index], val);
        index += index & (-index);
    }
}

int a[200000];

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

    memset(BIT2, 127, sizeof(BIT2));

    int m, n, k, t;
    cin >> m >> n >> k >> t;
    for (int i=0; i<m; i++)
        cin >> a[i];
    for (int i=0; i<k; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        update(200001 - d, r);
        update2(200001 - d, l);
    }

    sort(a, a + m, greater<int>());
    int l = 0, r = m;
    while (l < r) {
        int mid = (l + r) / 2;

        int L = getMin(200001 - (a[mid] + 1)), R = getMax(200001 - (a[mid] + 1));
        int timeConsumed = n + 1 + 2 * (R - L + 1);

        if (timeConsumed > t)
            r = mid;
        else
            l = mid + 1;
    }

    cout << l << "\n";

    return 0;
}


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

int BIT[200001] = {};

int getMax(int index) {
    int ret = 0;
    while (index > 0) {
        ret = max(ret, BIT[index]);
        index -= index & (-index);
    }
    return ret;
}

void update(int index, int val) {
    while (index <= 200000) {
        BIT[index] = max(BIT[index], val);
        index += index & (-index);
    }
}

int BIT2[200001];

int getMin(int index) {
    int ret = 1e9;
    while (index > 0) {
        ret = min(ret, BIT2[index]);
        index -= index & (-index);
    }
    return ret;
}

void update2(int index, int val) {
    while (index <= 200000) {
        BIT2[index] = min(BIT2[index], val);
        index += index & (-index);
    }
}

int a[200000];

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

    memset(BIT2, 127, sizeof(BIT2));

    int m, n, k, t;
    cin >> m >> n >> k >> t;
    for (int i=0; i<m; i++)
        cin >> a[i];
    for (int i=0; i<k; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        update(200001 - d, r);
        update2(200001 - d, l);
    }

    sort(a, a + m, greater<int>());
    int l = 0, r = m;
    while (l < r) {
        int mid = (l + r) / 2;

        int L = getMin(200001 - (a[mid] + 1)), R = getMax(200001 - (a[mid] + 1));
        int timeConsumed = n + 1 + (R == 0 ? 0 : 2 * (R - L + 1));

        if (timeConsumed > t)
            r = mid;
        else
            l = mid + 1;
    }

    cout << l << "\n";

    return 0;
}


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

struct Trap {
    int l, r, d;

    bool operator < (const Trap &other) const {
        if (d == other.d)
            return l < other.l;
        return d < other.d;
    }
};

int a[200000];
Trap traps[200000];

int BIT[200001] = {};

int getMax(int index) {
    int ret = 0;
    while (index > 0) {
        ret = max(ret, BIT[index]);
        index -= index & (-index);
    }
    return ret;
}

void update(int index, int val) {
    while (index <= 200000) {
        BIT[index] = max(BIT[index], val);
        index += index & (-index);
    }
}

int BIT2[200001];

int getMin(int index) {
    int ret = INT_MAX;
    while (index > 0) {
        ret = min(ret, BIT2[index]);
        index -= index & (-index);
    }
    return ret;
}

void update2(int index, int val) {
    while (index <= 200000) {
        BIT2[index] = min(BIT2[index], val);
        index += index & (-index);
    }
}

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

    memset(BIT2, 127, sizeof(BIT2));

    int m, n, k, t;
    cin >> m >> n >> k >> t;
    for (int i=0; i<m; i++)
        cin >> a[i];
    for (int i=0; i<k; i++) {
        cin >> traps[i].l >> traps[i].r >> traps[i].d;
        update(200001 - traps[i].d, traps[i].r);
        update2(200001 - traps[i].d, traps[i].l);
    }

    sort(a, a + m, greater<int>());
    sort(traps, traps + k);
    int l = 0, r = m;
    while (l < r) {
        int mid = (l + r) / 2, i = 0;

        int firstL = getMin(200001 - (a[mid] + 1));
        int squad = firstL - 1, you = firstL - 1, tt = t - firstL + 1;

        int lastR = getMax(200001 - (a[mid] + 1));
        long long timeConsumed = 2LL * (lastR - you) + n + 1 - squad;

        if (timeConsumed < 0 || timeConsumed > tt)
            r = mid;
        else
            l = mid + 1;
    }

    cout << l << "\n";

    return 0;
}


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

//int BIT[200001] = {};
//
//int getMax(int index) {
//    int ret = 0;
//    while (index > 0) {
//        ret = max(ret, BIT[index]);
//        index -= index & (-index);
//    }
//    return ret;
//}
//
//void update(int index, int val) {
//    while (index <= 200000) {
//        BIT[index] = max(BIT[index], val);
//        index += index & (-index);
//    }
//}
//
//int BIT2[200001];
//
//int getMin(int index) {
//    int ret = 1e9;
//    while (index > 0) {
//        ret = min(ret, BIT2[index]);
//        index -= index & (-index);
//    }
//    return ret;
//}
//
//void update2(int index, int val) {
//    while (index <= 200000) {
//        BIT2[index] = min(BIT2[index], val);
//        index += index & (-index);
//    }
//}

struct Trap {
    int l, r, d;

    bool operator < (const Trap &other) const {
        if (l == other.l)
            return r < other.r;
        return l < other.l;
    }
};

int a[200000];
Trap traps[200000];

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

    //memset(BIT2, 127, sizeof(BIT2));

    int m, n, k, t;
    cin >> m >> n >> k >> t;
    for (int i=0; i<m; i++)
        cin >> a[i];
    for (int i=0; i<k; i++)
        cin >> traps[i].l >> traps[i].r >> traps[i].d;

    sort(a, a + m, greater<int>());
    int l = 0, r = m;
    while (l < r) {
        int mid = (l + r) / 2;

        vector<Trap> v;
        for (int i=0; i<k; i++)
            if (traps[i].d > a[mid])
                v.push_back(traps[i]);

        sort(v.begin(), v.end());
        int single = 0, R = 0;
        for (Trap tp : v) {
            if (tp.l <= R) {
                single += max(0, tp.r - R);
                R = max(tp.r, R);
            } else {
                single += tp.r - tp.l + 1;
                R = tp.r;
            }
        }

        int timeConsumed = n + 1 + 2 * single;

        if (timeConsumed > t)
            r = mid;
        else
            l = mid + 1;
    }

    cout << l << "\n";

    return 0;
}


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

struct Trap {
    int l, r, d;

    bool operator < (const Trap &other) const {
        if (d == other.d)
            return l < other.l;
        return d < other.d;
    }
};

int a[200000];
Trap traps[200000];

int BIT[200001] = {};

int getMax(int index) {
    int ret = 0;
    while (index > 0) {
        ret = max(ret, BIT[index]);
        index -= index & (-index);
    }
    return ret;
}

void update(int index, int val) {
    while (index <= 200000) {
        BIT[index] = max(BIT[index], val);
        index += index & (-index);
    }
}

int BIT2[200001];

int getMin(int index) {
    int ret = INT_MAX;
    while (index > 0) {
        ret = min(ret, BIT2[index]);
        index -= index & (-index);
    }
    return ret;
}

void update2(int index, int val) {
    while (index <= 200000) {
        BIT2[index] = min(BIT2[index], val);
        index += index & (-index);
    }
}

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

    memset(BIT2, 127, sizeof(BIT2));

    int m, n, k, t;
    cin >> m >> n >> k >> t;
    for (int i=0; i<m; i++)
        cin >> a[i];
    for (int i=0; i<k; i++) {
        cin >> traps[i].l >> traps[i].r >> traps[i].d;
        update(200001 - traps[i].d, traps[i].r);
        update2(200001 - traps[i].d, traps[i].l);
    }

    sort(a, a + m, greater<int>());
    sort(traps, traps + k);
    int l = 0, r = m;
    while (l < r) {
        int mid = (l + r) / 2, i = 0;

        int firstL = getMin(200001 - (a[mid] + 1));
        int squad = firstL - 1, you = firstL - 1, tt = t - firstL + 1;

        int lastR = getMax(200001 - (a[mid] + 1));
        int timeConsumed = 2 * (lastR - you) + n + 1 - squad;

        if (timeConsumed > tt)
            r = mid;
        else
            l = mid + 1;
    }

    cout << l << "\n";

    return 0;
}


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

struct Trap {
    int l, r, d;

    bool operator < (const Trap &other) const {
        if (d == other.d)
            return l < other.l;
        return d < other.d;
    }
};

int a[200000];
Trap traps[200000];

int BIT[200001] = {};

int getMax(int index) {
    int ret = 0;
    while (index > 0) {
        ret = max(ret, BIT[index]);
        index -= index & (-index);
    }
    return ret;
}

void update(int index, int val) {
    while (index <= 200000) {
        BIT[index] = max(BIT[index], val);
        index += index & (-index);
    }
}

int BIT2[200001];

int getMin(int index) {
    int ret = INT_MAX;
    while (index > 0) {
        ret = min(ret, BIT2[index]);
        index -= index & (-index);
    }
    return ret;
}

void update2(int index, int val) {
    while (index <= 200000) {
        BIT2[index] = min(BIT2[index], val);
        index += index & (-index);
    }
}

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

    memset(BIT2, 127, sizeof(BIT2));

    int m, n, k, t;
    cin >> m >> n >> k >> t;
    for (int i=0; i<m; i++)
        cin >> a[i];
    for (int i=0; i<k; i++) {
        cin >> traps[i].l >> traps[i].r >> traps[i].d;
        update(200001 - traps[i].d, traps[i].r);
        update2(200001 - traps[i].d, traps[i].l);
    }

    sort(a, a + m, greater<int>());
    sort(traps, traps + k);
    int l = 0, r = m;
    while (l < r) {
        int mid = (l + r) / 2, i = 0;

        int firstL = getMin(200001 - (a[mid] + 1));
        int squad = firstL - 1, you = firstL - 1, tt = t - firstL + 1;

        int lastR = getMax(200001 - (a[mid] + 1));
        int timeConsumed = 2 * (lastR - you) + n + 1 - squad;

        if (timeConsumed < 0 || timeConsumed > tt)
            r = mid;
        else
            l = mid + 1;
    }

    cout << l << "\n";

    return 0;
}


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

struct Trap {
    int l, r, d;
};

int a[200000];
Trap traps[200000];

int BIT[200001] = {};

int getMax(int index) {
    int ret = 0;
    while (index > 0) {
        ret = max(ret, BIT[index]);
        index -= index & (-index);
    }
    return ret;
}

void update(int index, int val) {
    while (index <= 200000) {
        BIT[index] = max(BIT[index], val);
        index += index & (-index);
    }
}

int BIT2[200001];

int getMin(int index) {
    int ret = INT_MAX;
    while (index > 0) {
        ret = min(ret, BIT2[index]);
        index -= index & (-index);
    }
    return ret;
}

void update2(int index, int val) {
    while (index <= 200000) {
        BIT2[index] = min(BIT2[index], val);
        index += index & (-index);
    }
}

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

    memset(BIT2, 127, sizeof(BIT2));

    int m, n, k, t;
    cin >> m >> n >> k >> t;
    for (int i=0; i<m; i++)
        cin >> a[i];
    for (int i=0; i<k; i++) {
        cin >> traps[i].l >> traps[i].r >> traps[i].d;
        update(200001 - traps[i].d, traps[i].r);
        update2(200001 - traps[i].d, traps[i].l);
    }

    sort(a, a + m, greater<int>());
    int l = 0, r = m;
    while (l < r) {
        int mid = (l + r) / 2;

        int L = getMin(200001 - (a[mid] + 1)), R = getMax(200001 - (a[mid] + 1));
        int timeConsumed = n + 1 + 2 * (R - L + 1);

        if (timeConsumed > t)
            r = mid;
        else
            l = mid + 1;
    }

    cout << l << "\n";

    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

const int maxn = 2e5+100;
int soldier[maxn],m,n,k,t;

struct TRAP {
	int l,r,d;
	bool operator < (const TRAP& o) {
		return o.l==l? r < o.r : l < o.l;
	}
} trap[maxn];

bool cmp(const int& a,const int& b) { return a>b; }

bool check(int id) {
    int key = soldier[id];
    int pre,end,sum = 0;
    pre = end = 0;
    for(int i=0; i<=k; i++) {
        TRAP& now = trap[i];
        if(now.d > key) {
            if(now.l <= end) end = max(end,now.r);
            else {
                sum += end - pre;
                pre = now.l;
                end = now.r;
            }
        }
    }
    return sum*2+(n+1) <= t;
}

int binary_search() {
    int l = 0, r = m+1,mid;
    while(l+1<r) {
        mid = (l+r)>>1;
        if(check(mid)) l = mid;
        else r = mid;
    }
    return r;
}

int main() {
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=0; i<m; i++) scanf("%d",&soldier[i]);
	sort(soldier,soldier+m,cmp);
    for(int i=0; i<k; i++) {
        scanf("%d%d%d",&trap[i].l,&trap[i].r,&trap[i].d);
        trap[i].l--;
    }
    trap[k].l = trap[k].r = trap[k].d = maxn;
    sort(trap,trap+k+1);
    printf("%d\n",binary_search());
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

#define debug(x) printf(#x " = %d\n",x)

const int maxn = 2e5+100;
struct TRAP {
	int l,r,d;
	bool operator < (const TRAP& o) {
		return l==o.l? r < o.r : l < o.l;
	}
} trap[maxn];
int m,n,k,t,so[maxn];

bool cmp(int& a,int &b) { return a > b; }

bool check(int mini) {
	int sum = 0,per,end;
	per = end = 0;
	for(int i=0; i<=k; i++) {
		TRAP& now = trap[i];
		if(now.d > mini) {
			if(now.l <= end) end = now.r;
			else {
				sum += end - per+1;
				per = now.l;
				end = now.r;
			}
		}
	}
	return sum*2+n <= t;
}

int binarySearch() {
	int l=0,r=k+1,mid;
	while(l+1 < r) {
		mid = (l+r)>>1;
		if(check(so[mid])) l = mid;
		else r = mid;
	}
	return l;
}

int main() {
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=0; i<m; i++) scanf("%d",so+i);
	so[m] = 0;
	sort(so,so+m+1,cmp);
	for(int i=0; i<k; i++) {
		scanf("%d%d%d",&trap[i].l,&trap[i].r,&trap[i].d);
	}
	trap[k].l = trap[k].r = trap[k].d = maxn;
	sort(trap,trap+k+1);
	int ans = binarySearch() + 1;
	printf("%d\n",ans>k? 0 : ans);
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

const int maxn = 2e5+100;
int soldier[maxn],m,n,k,t;

struct TRAP {
	int l,r,d;
	bool operator < (const TRAP& o) {
		return o.l==l? r < o.r : l < o.l;
	}
} trap[maxn];

bool cmp(const int& a,const int& b) { return a>b; }

bool check(int id) {
    int key = soldier[id];
    int pre,end,sum = 0;
    pre = end = 0;
    for(int i=0; i<=k; i++) {
        TRAP& now = trap[i];
        if(now.d > key) {
            if(now.l <= end) end = max(end,now.r);
            else {
                sum += end - pre;
                pre = now.l;
                end = now.r;
            }
        }
    }
    return sum*2+(n+1) <= t;
}

int binary_search() {
    int l = 0, r = k+1,mid;
    while(l+1<r) {
        mid = (l+r)>>1;
        if(check(mid)) l = mid;
        else r = mid;
    }
    return r;
}

int main() {
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=0; i<m; i++) scanf("%d",&soldier[i]);
	sort(soldier,soldier+m,cmp);
    for(int i=0; i<k; i++) {
        scanf("%d%d%d",&trap[i].l,&trap[i].r,&trap[i].d);
        trap[i].l--;
    }
    trap[k].l = trap[k].r = trap[k].d = maxn;
    sort(trap,trap+k+1);
    printf("%d\n",binary_search());
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

#define debug(x) printf(#x " = %d\n",x)

const int maxn = 2e5+100;
struct TRAP {
	int l,r,d;
	bool operator < (const TRAP& o) {
		return l==o.l? r < o.r : l < o.l;
	}
} trap[maxn];
int m,n,k,t,so[maxn];

bool cmp(int& a,int& b) { return a > b; }

bool check(int mini) {
	int sum = 0,per,end;
	per = end = 0;
	for(int i=0; i<=k; i++) {
		TRAP& now = trap[i];
		if(now.d > mini) {
			if(now.l <= end+1) end = now.r;
			else {
				sum += end - per+1;
				per = now.l;
				end = now.r;
			}
		}
	}
	return sum*2+n+1 <= t;
}

int binarySearch() {
	int l=0,r=k+1,mid;
	while(l+1 < r) {
		mid = (l+r)>>1;
		if(check(so[mid])) l = mid;
		else r = mid;
	}
	return l;
}

int main() {
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=0; i<m; i++) scanf("%d",so+i);
	so[m] = 0;
	sort(so,so+m+1,cmp);
	for(int i=0; i<k; i++) {
		scanf("%d%d%d",&trap[i].l,&trap[i].r,&trap[i].d);
	}
	trap[k].l = trap[k].r = trap[k].d = maxn;
	sort(trap,trap+k+1);
	int ans = binarySearch() + 1;
	printf("%d\n",ans);
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

#define debug(x) printf(#x " = %d\n",x);
const int maxn = 2e5+100;
int soldier[maxn],m,n,k,t;

struct TRAP {
	int l,r,d;
	bool operator < (const TRAP& o) {
		return o.l==l? r < o.r : l < o.l;
	}
} trap[maxn];

bool cmp(const int& a,const int& b) { return a>b; }

bool check(int id) {
    int key = soldier[id];
    int pre,end,sum = 0;
    pre = end = 0;
    for(int i=0; i<=k; i++) {
        TRAP& now = trap[i];
        if(now.d > key) {
            if(now.l <= end) end = max(end,now.r);
            else {
                sum += end - pre;
                pre = now.l;
                end = now.r;
            }
        }
    }
    // debug(id);
    // debug(sum);
    return sum*2+(n+1) <= t;
}

int binary_search() {
    int l = 0, r = m+1,mid,ans;
    while(l+1<r) {
        mid = (l+r)>>1;
        if(check(mid)) l = mid;
        else r = mid;
    }
    return l;
}

int main() {
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=1; i<=m; i++) scanf("%d",&soldier[i]);
	sort(soldier+1,soldier+m+1,cmp);
    for(int i=0; i<k; i++) {
        scanf("%d%d%d",&trap[i].l,&trap[i].r,&trap[i].d);
        trap[i].l--;
    }
    trap[k].l = trap[k].r = trap[k].d = maxn;
    sort(trap,trap+k+1);
    printf("%d\n",binary_search());
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

const int maxn = 2e5+100;
int soldier[maxn],m,n,k,t;

struct TRAP {
	int l,r,d;
	bool operator < (const TRAP& o) {
		return o.l==l? r < o.r : l < o.l;
	}
} trap[maxn];

bool cmp(const int& a,const int& b) { return a>b; }

bool check(int mini) {
    int key = soldier[mini];
    int pre,end,sum = 0;
    pre = end = 0;
    for(int i=0; i<=k; i++) {
        TRAP& now = trap[i];
        if(now.d > key) {
            if(now.l <= end) end = max(end,now.r);
            else {
                sum += end - pre;
                pre = now.l;
                end = now.r;
            }
        }
    }
    return sum*2+(n+1) <= t;
}

int binary_search() {
    int l = 1, r = k,mid;
    while(l+1<r) {
        mid = (l+r)>>1;
        if(check(mid)) l = mid;
        else r = mid;
    }
    return r;
}

int main() {
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=0; i<m; i++) scanf("%d",&soldier[i]);
	sort(soldier,soldier+m,cmp);
    for(int i=0; i<k; i++) {
        scanf("%d%d%d",&trap[i].l,&trap[i].r,&trap[i].d);
        trap[i].l--;
    }
    trap[k].l = trap[k].r = trap[k].d = maxn;
    sort(trap,trap+k+1);
    printf("%d\n",binary_search());
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

#define debug(x) printf(#x " = %d\n",x)

const int maxn = 2e5+100;
struct TRAP {
	int l,r,d;
	bool operator < (const TRAP& o) {
		return l==o.l? r < o.r : l < o.l;
	}
} trap[maxn];
int m,n,k,t,so[maxn];

bool cmp(int& a,int& b) { return a > b; }

bool check(int mini) {
	int sum = 0,per,end;
	per = end = 0;
	for(int i=0; i<=k; i++) {
		TRAP& now = trap[i];
		if(now.d > mini) {
			if(now.l <= end+1) end = now.r;
			else {
				sum += end - per+1;
				per = now.l;
				end = now.r;
			}
		}
	}
	return sum*2+n <= t;
}

int binarySearch() {
	int l=0,r=k+1,mid;
	while(l+1 < r) {
		mid = (l+r)>>1;
		if(check(so[mid])) l = mid;
		else r = mid;
	}
	return l;
}

int main() {
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=0; i<m; i++) scanf("%d",so+i);
	so[m] = 0;
	sort(so,so+m+1,cmp);
	for(int i=0; i<k; i++) {
		scanf("%d%d%d",&trap[i].l,&trap[i].r,&trap[i].d);
	}
	trap[k].l = trap[k].r = trap[k].d = maxn;
	sort(trap,trap+k+1);
	int ans = binarySearch() + 1;
	printf("%d\n",ans>k? 0 : ans);
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

const int maxn = 2e5+100;
int soldier[maxn],m,n,k,t;

struct TRAP {
	int l,r,d;
	bool operator < (const TRAP& o) {
		return o.l==l? r < o.r : l < o.l;
	}
} trap[maxn];

bool check(int mini) {
    int key = soldier[mini];
    int pre,end,sum = 0;
    pre = end = 0;
    for(int i=0; i<=k; i++) {
        TRAP& now = trap[i];
        if(now.d > key) {
            if(now.l <= end) end = max(end,now.r);
            else {
                sum += end - pre;
                pre = now.l;
                end = now.r;
            }
        }
    }
    return sum*2+n <= t;
}

int binary_search() {
    int l = 0, r = k,mid;
    while(l+1<r) {
        mid = (l+r)>>1;
        if(check(mid)) r = mid;
        else l = mid;
    }
    //cout << soldier[l] << endl;
    return r;
}

int main() {
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=0; i<m; i++) scanf("%d",&soldier[i]);
	sort(soldier,soldier+m);
    for(int i=0; i<k; i++) {
        scanf("%d%d%d",&trap[i].l,&trap[i].r,&trap[i].d);
        trap[i].l--;
    }
    trap[k].l = trap[k].r = trap[k].d = maxn;
    sort(trap,trap+k+1);
    //for(int i=0; i<=k; i++) {
    //    cout << trap[i].l << " " << trap[i].r << " " << trap[i].d << endl;
    //}
    printf("%d\n",m - binary_search());
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

const int maxn = 2e5+100;
int soldier[maxn],m,n,k,t;

struct TRAP {
	int l,r,d;
	bool operator < (const TRAP& o) {
		return o.l==l? r < o.r : l < o.l;
	}
} trap[maxn];

bool check(int mini) {
    int key = soldier[mini];
    int pre,end,sum = 0;
    pre = end = 0;
    for(int i=0; i<=k; i++) {
        TRAP& now = trap[i];
        if(now.d > key) {
            if(now.l <= end) end = max(end,now.r);
            else {
                sum += end - pre;
                pre = now.l;
                end = now.r;
            }
        }
    }
    return sum*2+n < t;
}

int binary_search() {
    int l = 0, r = k,mid;
    while(l+1<r) {
        mid = (l+r)>>1;
        if(check(mid)) r = mid;
        else l = mid;
    }
    //cout << soldier[l] << endl;
    return r;
}

int main() {
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=0; i<m; i++) scanf("%d",&soldier[i]);
	sort(soldier,soldier+m);
    for(int i=0; i<k; i++) {
        scanf("%d%d%d",&trap[i].l,&trap[i].r,&trap[i].d);
        trap[i].l--;
    }
    trap[k].l = trap[k].r = trap[k].d = maxn;
    sort(trap,trap+k+1);
    printf("%d\n",m - binary_search());
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

const int maxn = 2e5+100;
int soldier[maxn],m,n,k,t;

struct TRAP {
	int l,r,d;
	bool operator < (const TRAP& o) {
		return o.l==l? r < o.r : l < o.l;
	}
} trap[maxn];

bool check(int mini) {
    int key = soldier[mini];
    int pre,end,sum = 0;
    for(int i=0; i<=k; i++) {
        TRAP& now = trap[i];
        if(now.d > key) {
            if(now.l <= end) end = max(end,now.r);
            else {
                sum += end - pre;
                pre = now.l;
                end = now.r;
            }
        }
    }
    return sum*2+n <= t;
}

int binary_search() {
    int l = 1, r = k+1,mid;
    while(l+1<r) {
        mid = (l+r)>>1;
        if(check(mid)) l = mid;
        else r = mid;
    }
    return l;
}

int main() {
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=0; i<m; i++) scanf("%d",&soldier[i]);
	sort(soldier,soldier+m);
    for(int i=0; i<k; i++) {
        scanf("%d%d%d",&trap[i].l,&trap[i].r,&trap[i].d);
        trap[i].l--;
    }
    trap[k].l = trap[k].r = trap[k].d = maxn;
    sort(trap,trap+k+1);
    printf("%d\n",m - binary_search());
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

const int maxn = 2e5+100;
int soldier[maxn],m,n,k,t;

struct TRAP {
	int l,r,d;
	bool operator < (const TRAP& o) {
		return o.l==l? r < o.r : l < o.l;
	}
} trap[maxn];

bool cmp(const int& a,const int& b) { return a>b; }

bool check(int id) {
    int key = soldier[id];
    int pre,end,sum = 0;
    pre = end = 0;
    for(int i=0; i<=k; i++) {
        TRAP& now = trap[i];
        if(now.d > key) {
            if(now.l <= end) end = max(end,now.r);
            else {
                sum += end - pre;
                pre = now.l;
                end = now.r;
            }
        }
    }
    return sum*2+(n+1) <= t;
}

int binary_search() {
    int l = 0, r = m,mid;
    while(l+1<r) {
        mid = (l+r)>>1;
        if(check(mid)) l = mid;
        else r = mid;
    }
    return r;
}

int main() {
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=0; i<m; i++) scanf("%d",&soldier[i]);
	sort(soldier,soldier+m,cmp);
    for(int i=0; i<k; i++) {
        scanf("%d%d%d",&trap[i].l,&trap[i].r,&trap[i].d);
        trap[i].l--;
    }
    trap[k].l = trap[k].r = trap[k].d = maxn;
    sort(trap,trap+k+1);
    printf("%d\n",binary_search());
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

#define debug(x) printf(#x " = %d\n",x)

const int maxn = 2e5+100;
struct TRAP {
	int l,r,d;
	bool operator < (const TRAP& o) {
		return l==o.l? r < o.r : l < o.l;
	}
} trap[maxn];
int m,n,k,t,so[maxn];

bool cmp(int& a,int& b) { return a > b; }

bool check(int mini) {
	int sum = 0,per,end;
	per = end = 0;
	for(int i=0; i<=k; i++) {
		TRAP& now = trap[i];
		if(now.d > mini) {
			if(now.l <= end+1) end = now.r;
			else {
				sum += end - per+1;
				per = now.l;
				end = now.r;
			}
		}
	}
	return sum*2+n <= t;
}

int binarySearch() {
	int l=0,r=k+1,mid;
	while(l+1 < r) {
		mid = (l+r)>>1;
		if(check(so[mid])) l = mid;
		else r = mid;
	}
	return l;
}

int main() {
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=0; i<m; i++) scanf("%d",so+i);
	so[m] = 0;
	sort(so,so+m+1,cmp);
	for(int i=0; i<k; i++) {
		scanf("%d%d%d",&trap[i].l,&trap[i].r,&trap[i].d);
	}
	trap[k].l = trap[k].r = trap[k].d = maxn;
	sort(trap,trap+k+1);
	int ans = binarySearch() + 1;
	printf("%d\n",ans);
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

const int maxn = 2e5+100;
int soldier[maxn],m,n,k,t;

struct TRAP {
	int l,r,d;
	bool operator < (const TRAP& o) {
		return o.l==l? r < o.r : l < o.l;
	}
} trap[maxn];

bool cmp(const int& a,const int& b) { return a>b; }

bool check(int mini) {
    int key = soldier[mini];
    int pre,end,sum = 0;
    pre = end = 0;
    for(int i=0; i<=k; i++) {
        TRAP& now = trap[i];
        if(now.d > key) {
            if(now.l <= end) end = max(end,now.r);
            else {
                sum += end - pre;
                pre = now.l;
                end = now.r;
            }
        }
    }
    return sum*2+(n+1) <= t;
}

int binary_search() {
    int l = 1, r = k+1,mid;
    while(l+1<r) {
        mid = (l+r)>>1;
        if(check(mid)) l = mid;
        else r = mid;
    }
    //cout << soldier[l] << endl;
    return r;
}

int main() {
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=0; i<m; i++) scanf("%d",&soldier[i]);
	sort(soldier,soldier+m,cmp);
    for(int i=0; i<k; i++) {
        scanf("%d%d%d",&trap[i].l,&trap[i].r,&trap[i].d);
        trap[i].l--;
    }
    trap[k].l = trap[k].r = trap[k].d = maxn;
    sort(trap,trap+k+1);
    printf("%d\n",binary_search());
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

const int maxn = 2e5+100;
int soldier[maxn],m,n,k,t;

struct TRAP {
	int l,r,d;
	bool operator < (const TRAP& o) {
		return o.l==l? r < o.r : l < o.l;
	}
} trap[maxn];

bool check(int mini) {
    int key = soldier[mini];
    int pre,end,sum = 0;
    pre = end = 0;
    for(int i=0; i<=k; i++) {
        TRAP& now = trap[i];
        if(now.d > key) {
            if(now.l <= end) end = max(end,now.r);
            else {
                sum += end - pre;
                pre = now.l;
                end = now.r;
            }
        }
    }
    return sum*2+(n+1) <= t;
}

int binary_search() {
    int l = 1, r = k+1,mid;
    while(l+1<r) {
        mid = (l+r)>>1;
        if(check(mid)) r = mid;
        else l = mid;
    }
    //cout << soldier[l] << endl;
    return r;
}

int main() {
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=0; i<m; i++) scanf("%d",&soldier[i]);
	sort(soldier,soldier+m);
    for(int i=0; i<k; i++) {
        scanf("%d%d%d",&trap[i].l,&trap[i].r,&trap[i].d);
        trap[i].l--;
    }
    trap[k].l = trap[k].r = trap[k].d = maxn;
    sort(trap,trap+k+1);
    printf("%d\n",m - binary_search());
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int m,n,k,t,cnt,ans;
int a[maxn],l[maxn],r[maxn],d[maxn],mxr[maxn],mnl[maxn];
bool check(int x){return 2*mxr[x+1]+n+1-2*mnl[x+1]<=t;}
int main()
{
	ans=0x3f3f3f3f;memset(mnl,0x3f,sizeof mnl);
	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",&l[i],&r[i],&d[i]),mxr[d[i]]=max(mxr[d[i]],r[i]),mnl[d[i]]=min(mnl[d[i]],l[i]);
	int L=1,R=maxn-5;
	for(int i=1;i<=R;i++)mxr[i]=max(mxr[i],mxr[i+1]),mnl[i]=min(mnl[i],mnl[i+1]);
//	printf("%d %d %d %d %d\n",mxr[1],mxr[2],mxr[3],mxr[4],mxr[5]);
//	printf("%d %d %d %d %d\n",mnl[1],mnl[2],mnl[3],mnl[4],mnl[5]);
	while(L!=R)
	{
		int mid=(L+R)>>1;
//		printf("%d %d %d %d\n",L,R,mid,check(mid));
		if(check(mid))R=mid,ans=min(ans,mid);
		else L=mid+1;
	}
	for(int i=1;i<=m;i++)if(a[i]>=ans)cnt++;
	printf("%d",cnt);
}
/*
2 5 2 11
1 0
2 4 2
3 4 1

5 6 4 12
1 2 3 4 5
1 5 2
1 2 5
2 2 5
3 4 3
*/


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int m,n,k,t,cnt,ans;
int a[maxn],l[maxn],r[maxn],d[maxn],mxr[maxn],mnl[maxn];
bool check(int x){return 2*mxr[x+1]+n+1-2*mnl[x]<=t;}
int main()
{
	ans=0x3f3f3f3f;memset(mnl,0x3f,sizeof mnl);
	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",&l[i],&r[i],&d[i]),mxr[d[i]]=max(mxr[d[i]],r[i]),mnl[d[i]]=min(mnl[d[i]],l[i]);
	int L=1,R=maxn-5;
	for(int i=1;i<=R;i++)mxr[i]=max(mxr[i],mxr[i+1]),mnl[i]=min(mnl[i],mnl[i+1]);
//	printf("%d %d %d %d %d\n",mxr[1],mxr[2],mxr[3],mxr[4],mxr[5]);
//	printf("%d %d %d %d %d\n",mnl[1],mnl[2],mnl[3],mnl[4],mnl[5]);
	while(L!=R)
	{
		int mid=(L+R)>>1;
//		printf("%d %d %d %d\n",L,R,mid,check(mid));
		if(check(mid))R=mid,ans=min(ans,mid);
		else L=mid+1;
	}
	for(int i=1;i<=m;i++)if(a[i]>=ans)cnt++;
	printf("%d",cnt);
}
/*
2 5 2 11
1 0
2 4 2
3 4 1

5 6 4 12
1 2 3 4 5
1 5 2
1 2 5
2 2 5
3 4 3
*/


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=2e5+10;
int m,n,k,t,cnt,ans;
int a[maxn],l[maxn],r[maxn],d[maxn],mxr[maxn],mnl[maxn];
bool check(int x){return 2*(mxr[x+1]-mnl[x+1]+1)+n+1<=t;}
main()
{
	ans=0x3f3f3f3f;memset(mnl,0x3f,sizeof mnl);
	scanf("%I64d%I64d%I64d%I64d",&m,&n,&k,&t);
	for(int i=1;i<=m;i++)scanf("%I64d",&a[i]);
	for(int i=1;i<=k;i++)scanf("%I64d%I64d%I64d",&l[i],&r[i],&d[i]),mxr[d[i]]=max(mxr[d[i]],r[i]),mnl[d[i]]=min(mnl[d[i]],l[i]);
	int L=1,R=maxn-5;
	for(int i=R;i>=1;i--)mxr[i]=max(mxr[i],mxr[i+1]),mnl[i]=min(mnl[i],mnl[i+1]);
//	printf("%d %d %d %d %d\n",mxr[1],mxr[2],mxr[3],mxr[4],mxr[5]);
//	printf("%d %d %d %d %d\n",mnl[1],mnl[2],mnl[3],mnl[4],mnl[5]);
	while(L!=R)
	{
		int mid=(L+R)>>1;
//		printf("%d %d %d %d\n",L,R,mid,check(mid));
		if(check(mid))R=mid,ans=min(ans,mid);
		else L=mid+1;
	}
	for(int i=1;i<=m;i++)if(a[i]>=ans)cnt++;
	printf("%I64d",cnt);
}
/*
2 5 2 9
1 0
2 4 1
3 4 2

5 6 4 13
1 2 3 4 5
1 5 2
1 2 5
2 2 5
3 4 3
*/


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

const int maxn=2e5+10;
int n,m,k,t;
int a[maxn],l[maxn],r[maxn],d[maxn];
int flag[maxn];
int L,R,ans;
bool check(int x)
{
	memset(flag,0,sizeof flag);
	for(int i=1;i<=k;i++)
	{
		if(d[i]>=x)
			flag[l[i]]=max(flag[l[i]],r[i]);
	}
	int state=0,l=0,cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(state)
		{
			state=max(state,flag[i]);
			if(state==i)cnt+=2*(state-l+1),state=0,l=0;
			flag[i]=1;
		}
		else
		{
			if(flag[i])state=flag[i],l=i;
		}
	}
	return cnt+n+1<=t;
}
int main()
{
	ans=0x3f3f3f3f;
	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",&l[i],&r[i],&d[i]);
	L=1;R=maxn-5;
	while(L!=R)
	{
		int mid=(L+R)>>1;
		if(check(mid+1))R=mid,ans=mid;
		else L=mid+1;
	}
	int cnt=0;
	for(int i=1;i<=m;i++)if(a[i]>=ans)cnt++;
	printf("%d\n",cnt);
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int m,n,k,t,cnt,ans;
int a[maxn],l[maxn],r[maxn],d[maxn],mxr[maxn];
bool check(int x){return 2*mxr[x+1]+n+1<=t;}
int main()
{
	ans=0x3f3f3f3f;
	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",&l[i],&r[i],&d[i]),mxr[d[i]]=max(mxr[d[i]],r[i]);
	int L=1,R=maxn-5;
	for(int i=1;i<=R;i++)mxr[i]=max(mxr[i],mxr[i+1]);
//	printf("%d %d %d %d %d\n",mxr[1],mxr[2],mxr[3],mxr[4],mxr[5]);
	while(L!=R)
	{
		int mid=(L+R)>>1;
//		printf("%d %d %d %d\n",L,R,mid,check(mid));
		if(check(mid))R=mid,ans=min(ans,mid);
		else L=mid+1;
	}
	for(int i=1;i<=m;i++)if(a[i]>=ans)cnt++;
	printf("%d",cnt);
}
/*
5 6 4 15
1 2 3 4 5
1 5 2
1 2 5
2 4 5
3 4 3
*/


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int n,m,k,t;
int a[maxn],l[maxn],r[maxn],d[maxn];
int flag[maxn];
int L,R,ans;
bool check(int x)
{
	memset(flag,0,sizeof flag);
	for(int i=1;i<=k;i++)
	{
		if(d[i]>=x)
			flag[l[i]]=max(flag[l[i]],r[i]);
	}
	int state=0,l=0,cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(state)
		{
			state=max(state,flag[i]);
			if(state==i)cnt+=2*(state-l+1),state=0,l=0;
			flag[i]=1;
		}
		else
		{
			if(flag[i])
			{
				if(flag[i]==i)cnt+=2;
				else state=flag[i],l=i;
			}
		}
	}
	return cnt+n+1<=t;
}
int main()
{
	ans=0x3f3f3f3f;
	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",&l[i],&r[i],&d[i]);
	L=1;R=maxn-5;
	while(L!=R)
	{
		int mid=(L+R)>>1;
		if(check(mid+1))R=mid,ans=mid;
		else L=mid+1;
	}
	int cnt=0;
	for(int i=1;i<=m;i++)if(a[i]>=ans)cnt++;
	printf("%d\n",cnt);
}
/*
1 3 2 8
1
1 1 2
3 3 2
*/


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int m,n,k,t,cnt,ans;
int a[maxn],l[maxn],r[maxn],d[maxn],mxr[maxn];
bool check(int x){return 2*x+n+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",&l[i],&r[i],&d[i]),mxr[d[i]]=max(mxr[d[i]],r[i]);
	int L=1,R=maxn-5;
	while(L!=R)
	{
		int mid=(L+R)>>1;
		if(check(mid))L=mid+1,ans=max(ans,mid);
		else R=mid;
	}
	for(int i=1;i<=m;i++)if(a[i]>=ans)cnt++;
	printf("%d",cnt);
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int m,n,k,t,cnt,ans;
int a[maxn],l[maxn],r[maxn],d[maxn],mxr[maxn],mnl[maxn];
bool check(int x){return 2*mxr[x+1]+n+1-2*(mnl[x+1]-1)<=t;}
int main()
{
	ans=0x3f3f3f3f;memset(mnl,0x3f,sizeof mnl);
	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",&l[i],&r[i],&d[i]),mxr[d[i]]=max(mxr[d[i]],r[i]),mnl[d[i]]=min(mnl[d[i]],l[i]);
	int L=1,R=maxn-5;
	for(int i=R;i>=1;i--)mxr[i]=max(mxr[i],mxr[i+1]),mnl[i]=min(mnl[i],mnl[i+1]);
//	printf("%d %d %d %d %d\n",mxr[1],mxr[2],mxr[3],mxr[4],mxr[5]);
//	printf("%d %d %d %d %d\n",mnl[1],mnl[2],mnl[3],mnl[4],mnl[5]);
	while(L!=R)
	{
		int mid=(L+R)>>1;
//		printf("%d %d %d %d\n",L,R,mid,check(mid));
		if(check(mid))R=mid,ans=min(ans,mid);
		else L=mid+1;
	}
	for(int i=1;i<=m;i++)if(a[i]>=ans)cnt++;
	printf("%d",cnt);
}
/*
2 5 2 11
1 0
2 4 2
3 4 1

5 6 4 13
1 2 3 4 5
1 5 2
1 2 5
2 2 5
3 4 3
*/


#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int m,n,k,t,cnt,ans,mx;
int a[maxn],l[maxn],r[maxn],d[maxn],mxr[maxn],mnl[maxn];
bool check(int x){return 2*mxr[x+1]+n+1-2*(mnl[x+1]-1)<=t;}
int main()
{
	ans=0x3f3f3f3f;memset(mnl,0x3f,sizeof mnl);
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=1;i<=m;i++)scanf("%d",&a[i]),mx=max(mx,a[i]);
	for(int i=1;i<=k;i++)scanf("%d%d%d",&l[i],&r[i],&d[i]),mxr[d[i]]=max(mxr[d[i]],r[i]),mnl[d[i]]=min(mnl[d[i]],l[i]);
	int L=1,R=maxn-5;
	for(int i=R;i>=1;i--)mxr[i]=max(mxr[i],mxr[i+1]),mnl[i]=min(mnl[i],mnl[i+1]);
//	printf("%d %d %d %d %d\n",mxr[1],mxr[2],mxr[3],mxr[4],mxr[5]);
//	printf("%d %d %d %d %d\n",mnl[1],mnl[2],mnl[3],mnl[4],mnl[5]);
	for(int i=1;i<=mx;i++)
		if(check(i))ans=min(ans,i);
	for(int i=1;i<=m;i++)if(a[i]>=ans)cnt++;
	printf("%d",cnt);
}
/*
2 5 2 11
1 0
2 4 2
3 4 1

5 6 4 12
1 2 3 4 5
1 5 2
1 2 5
2 3 5
3 5 3

*/


#include<bits/stdc++.h>
#define se set<pair<int,int> >::iterator
using namespace std;
int m,n,k,t;
const int maxn=1e6+5;
int a[maxn];
vector<int> pd[maxn];
vector<pair<int,int> > g[maxn];
int cnt[maxn];
inline bool check(int v){
	int x=0;
	int ans=0;
	for(int i=1;i<=n;i++)cnt[i]=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<pd[i].size();j++){
			if(pd[i][j]>v)cnt[i]++;
		}
	}
	while(x<=n){
		int pos=x,to=x;
		for(int i=x;i<=n;i++){
			for(int j=0;j<g[i].size();j++){
				if(g[i][j].first>v)cnt[g[i][j].second]--;
			}
			while(x<=n){
				if(cnt[x+1]){
					break;
				}
				x++;
				if(x>i){
					for(int j=0;j<g[x].size();j++){
						if(g[x][j].first>v)cnt[g[x][j].second]--;
					}
				}
			}
			if(i-pos<(x-pos<<1)){
				to=i;
				break;
			}
		}
		//printf("%d %d %d\n",pos,x,to);
		if(x==pos){
			//printf("v=%d x=%d pos=%d\n",v,x,pos);
			return 0;
		}
		ans+=(to-pos<<1)+x-pos;
	}
	//printf("%d %d\n",v,ans);
	return ans<=t;
}
int main(){
#ifndef ONLINE_JUDGE
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	sort(a+1,a+m+1);
	for(int i=1;i<=k;i++){
		int l,r,d;
		scanf("%d%d%d",&l,&r,&d);
		pd[l].push_back(d);
		g[r].push_back(make_pair(d,l));
	}
	int l=1,r=n,ans=0;
	while(l<=r){
		int mid=l+r>>1;
		if(check(a[mid])){
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	printf("%d\n",m-ans+1);
	return 0;
}


#include<bits/stdc++.h>
#define int long long
#define se set<pair<int,int> >::iterator
using namespace std;
int m,n,k,t;
const int maxn=1e6+5;
int a[maxn];
vector<int> pd[maxn];
vector<pair<int,int> > g[maxn];
int cnt[maxn];
inline bool check(int v){
	int x=0;
	int ans=0;
	for(int i=1;i<=n;i++)cnt[i]=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<pd[i].size();j++){
			if(pd[i][j]>v)cnt[i]++;
		}
	}
	while(x<=n){
		int pos=x,to=x;
		for(int i=x;i<=n;i++){
			for(int j=0;j<g[i].size();j++){
				if(g[i][j].first>v)cnt[g[i][j].second]--;
			}
			while(x<=n){
				if(cnt[x+1]){
					break;
				}
				x++;
			}
			if(i-pos<(x-pos<<1)){
				to=i;
				break;
			}
		}
		//printf("%lld %lld %lld\n",pos,x,to);
		if(x==pos)return 0;
		ans+=(to-pos<<1)+x-pos;
	}
	//printf("%lld %lld\n",v,ans);
	return ans<=t;
}
signed main(){
#ifndef ONLINE_JUDGE
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
	scanf("%lld%lld%lld%lld",&m,&n,&k,&t);
	for(int i=1;i<=m;i++)scanf("%lld",&a[i]);
	sort(a+1,a+m+1);
	for(int i=1;i<=k;i++){
		int l,r,d;
		scanf("%lld%lld%lld",&l,&r,&d);
		pd[l].push_back(d);
		g[r].push_back(make_pair(d,l));
	}
	int l=1,r=n,ans;
	while(l<=r){
		int mid=l+r>>1;
		if(check(a[mid])){
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	printf("%lld\n",m-ans+1);
	return 0;
}


#include<bits/stdc++.h>
#define se set<pair<int,int> >::iterator
using namespace std;
int m,n,k,t;
const int maxn=1e6+5;
int a[maxn];
vector<int> pd[maxn];
vector<pair<int,int> > g[maxn];
int cnt[maxn];
inline bool check(int v){
	int x=0;
	int ans=0;
	for(int i=1;i<=n;i++)cnt[i]=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<pd[i].size();j++){
			if(pd[i][j]>v)cnt[i]++;
		}
	}
	while(x<=n){
		int pos=x,to=x;
		for(int i=x;i<=n;i++){
			for(int j=0;j<g[i].size();j++){
				if(g[i][j].first>v)cnt[g[i][j].second]--;
			}
			while(x<=n){
				if(cnt[x+1]){
					break;
				}
				x++;
			}
			if(i-pos<(x-pos<<1)){
				to=i;
				break;
			}
		}
		//printf("%d %d %d\n",pos,x,to);
		if(x==pos){
			printf("x=%d pos=%d\n",x,pos);
			return 0;
		}
		ans+=(to-pos<<1)+x-pos;
	}
	//printf("%d %d\n",v,ans);
	return ans<=t;
}
int main(){
#ifndef ONLINE_JUDGE
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	sort(a+1,a+m+1);
	for(int i=1;i<=k;i++){
		int l,r,d;
		scanf("%d%d%d",&l,&r,&d);
		pd[l].push_back(d);
		g[r].push_back(make_pair(d,l));
	}
	int l=1,r=n,ans=0;
	while(l<=r){
		int mid=l+r>>1;
		if(check(a[mid])){
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	printf("%d\n",m-ans+1);
	return 0;
}


#include<bits/stdc++.h>
#define se set<pair<int,int> >::iterator
using namespace std;
int m,n,k,t;
const int maxn=1e6+5;
int a[maxn];
vector<int> pd[maxn];
vector<pair<int,int> > g[maxn];
int cnt[maxn];
inline bool check(int v){
	int x=0;
	int ans=0;
	for(int i=1;i<=n;i++)cnt[i]=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<pd[i].size();j++){
			if(pd[i][j]>v)cnt[i]++;
		}
	}
	while(x<=n){
		int pos=x,to=x;
		for(int i=x;i<=n;i++){
			for(int j=0;j<g[i].size();j++){
				if(g[i][j].first>v)cnt[g[i][j].second]--;
			}
			while(x<=n){
				if(cnt[x+1]){
					break;
				}
				x++;
				if(x>i){
					for(int j=0;j<g[x].size();j++){
						if(g[x][j].first>v)cnt[g[x][j].second]--;
					}
				}
			}
			if(i-pos<(x-pos<<1)){
				to=i;
				break;
			}
		}
		//printf("%d %d %d\n",pos,x,to);
		if(x==pos){
			//printf("v=%d x=%d pos=%d\n",v,x,pos);
			return 0;
		}
		ans+=(to-pos<<1)+x-pos;
	}
	//printf("%d %d\n",v,ans);
	return ans<=t;
}
int main(){
#ifndef ONLINE_JUDGE
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	sort(a+1,a+m+1);
	for(int i=1;i<=k;i++){
		int l,r,d;
		scanf("%d%d%d",&l,&r,&d);
		pd[l].push_back(d);
		g[r].push_back(make_pair(d,l));
	}
	int l=1,r=m,ans=m+1;
	while(l<=r){
		int mid=l+r>>1;
		if(check(a[mid])){
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	printf("%d\n",m-ans+1);
	return 0;
}


#include<bits/stdc++.h>
#define se set<pair<int,int> >::iterator
using namespace std;
int m,n,k,t;
const int maxn=1e6+5;
int a[maxn];
vector<int> pd[maxn];
vector<pair<int,int> > g[maxn];
int cnt[maxn];
inline bool check(int v){
	int x=0;
	int ans=0;
	for(int i=1;i<=n;i++)cnt[i]=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<pd[i].size();j++){
			if(pd[i][j]>v)cnt[i]++;
		}
	}
	while(x<=n){
		int pos=x,to=x;
		for(int i=x;i<=n;i++){
			for(int j=0;j<g[i].size();j++){
				if(g[i][j].first>v)cnt[g[i][j].second]--;
			}
			while(x<=n){
				if(cnt[x+1]){
					break;
				}
				x++;
				if(x>i){
					for(int j=0;j<g[x].size();j++){
						if(g[x][j].first>v)cnt[g[x][j].second]--;
					}
				}
			}
			if(i-pos<(x-pos<<1)){
				to=i;
				break;
			}
		}
		//printf("%d %d %d\n",pos,x,to);
		if(x==pos){
			//printf("v=%d x=%d pos=%d\n",v,x,pos);
			return 0;
		}
		ans+=(to-pos<<1)+x-pos;
	}
	//printf("%d %d\n",v,ans);
	return ans<=t;
}
int main(){
#ifndef ONLINE_JUDGE
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	sort(a+1,a+m+1);
	for(int i=1;i<=k;i++){
		int l,r,d;
		scanf("%d%d%d",&l,&r,&d);
		pd[l].push_back(d);
		g[r].push_back(make_pair(d,l));
	}
	int l=0,r=m,ans=0;
	while(l<=r){
		int mid=l+r>>1;
		if(check(a[mid])){
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	printf("%d\n",m-ans+1);
	return 0;
}


#include<bits/stdc++.h>
#define se set<pair<int,int> >::iterator
using namespace std;
int m,n,k,t;
const int maxn=1e6+5;
int a[maxn];
vector<int> pd[maxn];
vector<pair<int,int> > g[maxn];
int cnt[maxn];
inline bool check(int v){
	int x=0;
	int ans=0;
	for(int i=1;i<=n;i++)cnt[i]=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<pd[i].size();j++){
			if(pd[i][j]>v)cnt[i]++;
		}
	}
	while(x<=n){
		int pos=x,to=x;
		for(int i=x;i<=n;i++){
			for(int j=0;j<g[i].size();j++){
				if(g[i][j].first>v)cnt[g[i][j].second]--;
			}
			while(x<=n){
				if(cnt[x+1]){
					break;
				}
				x++;
			}
			if(i-pos<(x-pos<<1)){
				to=i;
				break;
			}
		}
		//printf("%d %d %d\n",pos,x,to);
		if(x==pos)return 0;
		ans+=(to-pos<<1)+x-pos;
	}
	//printf("%d %d\n",v,ans);
	return ans<=t;
}
int main(){
#ifndef ONLINE_JUDGE
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	sort(a+1,a+m+1);
	for(int i=1;i<=k;i++){
		int l,r,d;
		scanf("%d%d%d",&l,&r,&d);
		pd[l].push_back(d);
		g[r].push_back(make_pair(d,l));
	}
	int l=1,r=n,ans;
	while(l<=r){
		int mid=l+r>>1;
		if(check(a[mid])){
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	printf("%d\n",m-ans+1);
	return 0;
}


#include<bits/stdc++.h>
#define se set<pair<int,int> >::iterator
using namespace std;
int m,n,k,t;
const int maxn=1e6+5;
int a[maxn];
vector<int> pd[maxn];
vector<pair<int,int> > g[maxn];
int cnt[maxn];
inline bool check(int v){
	int x=0;
	int ans=0;
	for(int i=1;i<=n;i++)cnt[i]=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<pd[i].size();j++){
			if(pd[i][j]>v)cnt[i]++;
		}
	}
	while(x<=n){
		int pos=x,to=x;
		for(int i=x;i<=n;i++){
			for(int j=0;j<g[i].size();j++){
				if(g[i][j].first>v)cnt[g[i][j].second]--;
			}
			while(x<=n){
				if(cnt[x+1]){
					break;
				}
				x++;
			}
			if(i-pos<(x-pos<<1)){
				to=i;
				break;
			}
		}
		//printf("%d %d %d\n",pos,x,to);
		if(x==pos)return 0;
		ans+=(to-pos<<1)+x-pos;
	}
	//printf("%d %d\n",v,ans);
	return ans<=t;
}
int main(){
#ifndef ONLINE_JUDGE
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	sort(a+1,a+m+1);
	for(int i=1;i<=k;i++){
		int l,r,d;
		scanf("%d%d%d",&l,&r,&d);
		pd[l].push_back(d);
		g[r].push_back(make_pair(d,l));
	}
	int l=1,r=n,ans=0;
	while(l<=r){
		int mid=l+r>>1;
		if(check(a[mid])){
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	printf("%d\n",m-ans+1);
	return 0;
}


#include<bits/stdc++.h>
#define se set<pair<int,int> >::iterator
using namespace std;
int m,n,k,t;
const int maxn=1e6+5;
int a[maxn];
vector<int> pd[maxn];
vector<pair<int,int> > g[maxn];
int cnt[maxn];
inline bool check(int v){
	int x=0;
	int ans=0;
	for(int i=1;i<=n;i++)cnt[i]=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<pd[i].size();j++){
			if(pd[i][j]>v)cnt[i]++;
		}
	}
	while(x<=n){
		int pos=x,to=x;
		for(int i=x;i<=n;i++){
			for(int j=0;j<g[i].size();j++){
				if(g[i][j].first>v)cnt[g[i][j].second]--;
			}
			while(x<=n){
				if(cnt[x+1]){
					break;
				}
				x++;
				if(x>i){
					for(int j=0;j<g[x].size();j++){
						if(g[x][j].first>v)cnt[g[x][j].second]--;
					}
				}
			}
			if(i<x){
				to=i;
				break;
			}
		}
		//printf("%d %d %d\n",pos,x,to);
		if(x==pos){
			//printf("v=%d x=%d pos=%d\n",v,x,pos);
			return 0;
		}
		ans+=(to-pos<<1)+x-pos;
	}
	//printf("%d %d\n",v,ans);
	return ans<=t;
}
int main(){
#ifndef ONLINE_JUDGE
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	sort(a+1,a+m+1);
	for(int i=1;i<=k;i++){
		int l,r,d;
		scanf("%d%d%d",&l,&r,&d);
		pd[l].push_back(d);
		g[r].push_back(make_pair(d,l));
	}
	int l=1,r=m,ans=m+1;
	while(l<=r){
		int mid=l+r>>1;
		if(check(a[mid])){
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	printf("%d\n",m-ans+1);
	return 0;
}


#include<bits/stdc++.h>
#define se set<pair<int,int> >::iterator
using namespace std;
int m,n,k,t;
const int maxn=1e6+5;
int a[maxn];
vector<int> pd[maxn];
vector<pair<int,int> > g[maxn];
int cnt[maxn];
inline bool check(int v){
	int x=0;
	int ans=0;
	for(int i=1;i<=n;i++)cnt[i]=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<pd[i].size();j++){
			if(pd[i][j]>v)cnt[i]++;
		}
	}
	while(x<=n){
		int pos=x,to=x;
		for(int i=x;i<=n;i++){
			for(int j=0;j<g[i].size();j++){
				if(g[i][j].first>v)cnt[g[i][j].second]--;
			}
			while(x<=n){
				if(cnt[x+1]){
					break;
				}
				x++;
			}
			if(i-pos<(x-pos<<1)){
				to=i;
				break;
			}
		}
		//printf("%d %d %d\n",pos,x,to);
		if(x==pos){
			printf("v=%d x=%d pos=%d\n",v,x,pos);
			return 0;
		}
		ans+=(to-pos<<1)+x-pos;
	}
	//printf("%d %d\n",v,ans);
	return ans<=t;
}
int main(){
#ifndef ONLINE_JUDGE
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	sort(a+1,a+m+1);
	for(int i=1;i<=k;i++){
		int l,r,d;
		scanf("%d%d%d",&l,&r,&d);
		pd[l].push_back(d);
		g[r].push_back(make_pair(d,l));
	}
	int l=1,r=n,ans=0;
	while(l<=r){
		int mid=l+r>>1;
		if(check(a[mid])){
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	printf("%d\n",m-ans+1);
	return 0;
}


#include<bits/stdc++.h>
#define se set<pair<int,int> >::iterator
using namespace std;
int m,n,k,t;
const int maxn=1e6+5;
int a[maxn];
vector<int> pd[maxn];
vector<pair<int,int> > g[maxn];
int cnt[maxn];
inline bool check(int v){
	int x=0;
	int ans=0;
	for(int i=1;i<=n;i++)cnt[i]=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<pd[i].size();j++){
			if(pd[i][j]>v)cnt[i]++;
		}
	}
	while(x<=n){
		int pos=x,to=x;
		for(int i=x;i<=n;i++){
			for(int j=0;j<g[i].size();j++){
				if(g[i][j].first>v)cnt[g[i][j].second]--;
			}
			while(x<=n){
				if(cnt[x+1]){
					break;
				}
				x++;
			}
			if(i-pos<(x-pos<<1)){
				to=i;
				break;
			}
		}
		//printf("%d %d %d\n",pos,x,to);
		if(x==pos){
			//printf("x=%d pos=%d\n",x,pos);
			return 0;
		}
		ans+=(to-pos<<1)+x-pos;
	}
	//printf("%d %d\n",v,ans);
	return ans<=t;
}
int main(){
#ifndef ONLINE_JUDGE
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	sort(a+1,a+m+1);
	for(int i=1;i<=k;i++){
		int l,r,d;
		scanf("%d%d%d",&l,&r,&d);
		pd[l].push_back(d);
		g[r].push_back(make_pair(d,l));
	}
	int l=1,r=m,ans=m+1;
	while(l<=r){
		int mid=l+r>>1;
		if(check(a[mid])){
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	printf("%d\n",m-ans+1);
	return 0;
}


#include<bits/stdc++.h>
#define se set<pair<int,int> >::iterator
using namespace std;
int m,n,k,t;
const int maxn=1e6+5;
int a[maxn];
vector<int> pd[maxn];
vector<pair<int,int> > g[maxn];
int cnt[maxn];
inline bool check(int v){
	int x=0;
	int ans=0;
	for(int i=1;i<=n;i++)cnt[i]=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<pd[i].size();j++){
			if(pd[i][j]>v)cnt[i]++;
		}
	}
	while(x<=n){
		int pos=x,to=x;
		for(int i=x;i<=n;i++){
			for(int j=0;j<g[i].size();j++){
				if(g[i][j].first>v)cnt[g[i][j].second]--;
			}
			while(x<=n){
				if(cnt[x+1]){
					break;
				}
				x++;
				if(x>i){
					for(int j=0;j<g[x].size();j++){
						if(g[x][j].first>v)cnt[g[x][j].second]--;
					}
				}
			}
			if(i-pos<(x-pos<<1)){
				to=i;
				break;
			}
		}
		//printf("%d %d %d\n",pos,x,to);
		if(x==pos){
			//printf("v=%d x=%d pos=%d\n",v,x,pos);
			return 0;
		}
		ans+=(to-pos<<1)+x-pos;
	}
	//printf("%d %d\n",v,ans);
	return ans<=t;
}
int main(){
#ifndef ONLINE_JUDGE
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	sort(a+1,a+m+1);
	for(int i=1;i<=k;i++){
		int l,r,d;
		scanf("%d%d%d",&l,&r,&d);
		pd[l].push_back(d);
		g[r].push_back(make_pair(d,l));
	}
	int l=1,r=m,ans=0;
	while(l<=r){
		int mid=l+r>>1;
		if(check(a[mid])){
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	printf("%d\n",m-ans+1);
	return 0;
}


#include<bits/stdc++.h>
#define se set<pair<int,int> >::iterator
using namespace std;
int m,n,k,t;
const int maxn=1e6+5;
int a[maxn];
vector<int> pd[maxn];
vector<pair<int,int> > g[maxn];
int cnt[maxn];
inline bool check(int v){
	int x=0;
	int ans=0;
	for(int i=1;i<=n;i++)cnt[i]=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<pd[i].size();j++){
			if(pd[i][j]>v)cnt[i]++;
		}
	}
	while(x<=n){
		int pos=x,to=x;
		for(int i=x;i<=n;i++){
			for(int j=0;j<g[i].size();j++){
				if(g[i][j].first>v)cnt[g[i][j].second]--;
			}
			while(x<=n){
				if(cnt[x+1]){
					break;
				}
				x++;
			}
			if(i-pos<(x-pos<<1)){
				to=i;
				break;
			}
		}
		//printf("%d %d %d\n",pos,x,to);
		//if(x==pos)return 0;
		ans+=(to-pos<<1)+x-pos;
	}
	//printf("%d %d\n",v,ans);
	return ans<=t;
}
int main(){
#ifndef ONLINE_JUDGE
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
	scanf("%d%d%d%d",&m,&n,&k,&t);
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	sort(a+1,a+m+1);
	for(int i=1;i<=k;i++){
		int l,r,d;
		scanf("%d%d%d",&l,&r,&d);
		pd[l].push_back(d);
		g[r].push_back(make_pair(d,l));
	}
	int l=1,r=n,ans=0;
	while(l<=r){
		int mid=l+r>>1;
		if(check(a[mid])){
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	printf("%d\n",m-ans+1);
	return 0;
}