#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <stdlib.h>
#include <ctime>
#include <cmath>
#include <complex>
#include <iostream>
#include <cctype>
#include <cstring>
#include <bitset>
#include <stack>
#include <functional>
#include <cassert>
#include <tuple>
#include <iomanip>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define ldb long double
#define mt make_tuple
template<typename T> bool ckmn(T &a, T b){ T c=a;a=min(a,b);return a!=c;}
template<typename T> bool ckmx(T &a, T b){ T c=a;a=max(a,b);return a!=c;}
const int N=100050;
const ll inf=9e18;
int a[N],b[N];
bool can[N];
int n,m,v,p;
bool Check(int mid)
{
	if(mid<=p) return 1;
	if(a[mid]+m<a[p]) return 0;
	int ost=max(0,v-(n-mid+1)-(p-1));
	if(ost==0) return 1;
	for(int i=p;i<mid;i++) b[i-p+1]=a[mid]+m-a[i];
	int sz=mid-p;
	vector<pair<int,int>> v;
	v.push_back({-1,0});
	for(int i=1;i<=sz;i++)
	{
		//printf("%i ",b[i]);
		if(v.empty() || v.back().first!=b[i]) v.pb({b[i],0});
		v[(int)v.size()-1].second++;
	}
	//printf("\n");
	//reverse(v.begin(),v.end());
	//for(auto p:v) printf("(%i %i) ",p.first,p.second);
	//printf("\n");
	int work=m;
	int pre=0,sub=0;
	stack<pair<ll,int>> vals;
	vals.push({inf,0});
	//printf("mid:%i ost:%i\n",mid,ost);
	while(pre+v.back().second<ost)
	{
		pre+=v.back().second;
		vals.push(v.back());
		//printf(":D\n");
		v.pop_back();
	}
	int val_z,sz0,sz1;
	val_z=v.back().first;
	sz0=v.back().second;
	sz1=0;
	v.pop_back();
	auto BinarySearch=[&]()
	{
		int bot=0,top=work,mid,ans=0;
		ll val_y=vals.top().first-sub;
		int val_w=v.back().first;
		while(top>=bot)
		{
			mid=top+bot>>1;
			ll y=val_y-mid;
			int z=val_z-((ll)mid*(ost-pre)+sz1)/(sz0+sz1);
			int lo=((ll)mid*(ost-pre)+sz1)%(sz0+sz1);
			int w=val_w;
			bool ok=1;
			if(z==0 && lo>0) ok=0;
			if(y<z) ok=0;
			if(z<w) ok=0;
			if(ok) bot=mid+1,ans=mid;
			else top=mid-1;
		}
		return ans;
	};
	while(work)
	{
        int now=BinarySearch();
        //printf("%i %i %i %i %lld\n",val_z,sz0,sz1,now,vals.top().first-sub);
        if(now==0) return 0;
        work-=now;
        val_z-=((ll)now*(ost-pre)+sz1)/(sz0+sz1);
        int tmp_sz=((ll)now*(ost-pre)+sz1)%(sz0+sz1);
        tie(sz0,sz1)=mp(sz0+sz1-tmp_sz,tmp_sz);
        sub+=now;
        if(vals.top().first-sub==val_z)
		{
			sz0+=vals.top().second;
			pre-=vals.top().second;
			vals.pop();
		}
		if(v.back().first==val_z)
		{
			sz0+=v.back().second;
			v.pop_back();
		}
	}
	return 1;
}
int main()
{
	scanf("%i %i %i %i\n",&n,&m,&v,&p);
	for(int i=1;i<=n;i++) scanf("%i",&a[i]);
	sort(a+1,a+1+n);
	reverse(a+1,a+1+n);
	int ans=0,top=n,bot=1,mid;
	while(top>=bot)
	{
		mid=top+bot>>1;
		if(Check(mid)) ans=mid,bot=mid+1;
		else top=mid-1;
	}
	/*for(int i=1;i<=n;i++)
	{
		if(i==1 || a[i]!=a[i-1])
		{
			if(i<=p) can[i]=1;
			else
			{
				int need=a[p];
				int have=a[i]+m;
				int ost=max(0,v-(n-i+1));
				if(ost>=p) need+=m;
				if(have>=need) can[i]=1;
				else can[i]=0;
			}
		}
		else can[i]=can[i-1];
		if(can[i]) ans++;
	}*/
	//for(int i=1;i<=n;i++) printf("%i ",a[i]);printf("\n");
	//for(int i=1;i<=n;i++) printf("%i ",can[i]);printf("\n");
	printf("%i\n",ans);
	return 0;
}

Measured memory_bytes: 2784