Problem:
Score : 700 points

Problem Statement

N problems are proposed for an upcoming contest. Problem i has an initial integer score of A_i points.

M judges are about to vote for problems they like. Each judge will choose exactly V problems, independently from the other judges,
and increase the score of each chosen problem by 1.

After all M judges cast their vote, the problems will be sorted in non-increasing order of score, and the first P problems will be chosen for the problemset.
Problems with the same score can be ordered arbitrarily, this order is decided by the chief judge.

How many problems out of the given N have a chance to be chosen for the problemset?

Constraints

2 \le N \le 10^5

1 \le M \le 10^9

1 \le V \le N - 1

1 \le P \le N - 1

0 \le A_i \le 10^9

Input

Input is given from Standard Input in the following format:

N M V P
A_1 A_2 ... A_N

Output

Print the number of problems that have a chance to be chosen for the problemset.

Sample Input 1

6 1 2 2
2 1 1 3 0 2

Sample Output 1

5

If the only judge votes for problems 2 and 5, the scores will be 2 2 1 3 1 2.
The problemset will consist of problem 4 and one of problems 1, 2, or 6.

If the only judge votes for problems 3 and 4, the scores will be 2 1 2 4 0 2.
The problemset will consist of problem 4 and one of problems 1, 3, or 6.

Thus, problems 1, 2, 3, 4, and 6 have a chance to be chosen for the problemset. On the contrary, there is no way for problem 5 to be chosen.

Sample Input 2

6 1 5 2
2 1 1 3 0 2

Sample Output 2

3

Only problems 1, 4, and 6 have a chance to be chosen.

Sample Input 3

10 4 8 5
7 2 3 6 1 6 5 4 6 5

Sample Output 3

8

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};



const int MAX_N = 1<<18;
int dat[2 * MAX_N -1];
int ni;

struct SegmentTree{
    SegmentTree(int n_){
        ni=1;
        while(ni<n_) ni*= 2;
        for(int i=0;i<2*ni-1;i++){
            dat[i]=0;
        }
    }
    int query(int k){
        k += ni-1;
        int count=dat[k];
        while(k>0){
            k=(k-1)/2;
            count+=dat[k];
        }
        return count;
    }
    void update(int a,int b,int k,int p,int l,int r){
        if(r<=a || b<=l) return;
        if(a<=l && r<=b){
            dat[k]+=p;
        }
        else{
            update(a,b,k*2+1,p,l,(l+r)/2);
            update(a,b,k*2+2,p,(l+r)/2,r);
        }
    }
};



ll n,m,v,p;
ll a[100010];

bool ok(ll k){
    ll b[100010]={},c[100010]={};
    rep(i,n) b[i]=a[i],c[i]=a[i];
    // reverse(c,c+n);
    // ll s=lower_bound(c,c+n,b[p-1])-c-1;
    // s=n-1-s;
    /*
    if(k<s){
        // cout<<"11111"<<endl;
        return true;
    }
    */
    if(k<p) return true;
    ll t=n-k;
    ll N=k;
    ll V=v-t;
    if(V<=0){
        ll cnt=0;
        rep(i,k){
            if(a[i]>b[k]+m) cnt++;
        }
        if(cnt<p) return true;
        else return false;
    }
    if(N<=V) return false;
    ll d[100010]={};
    rep(i,N){
        d[i]=b[k]+m-b[i];
    }
    SegmentTree sg(N);
    rep(i,N){
        sg.update(i,i+1,0,d[i],0,N);
    }
    ll cnt=0;
    rep(i,N-V+1){
        ll Q=sg.query(i);
        if(Q>0){
            sg.update(i,i+V,0,-Q,0,N);
            cnt+=Q;
        }
    }
    sg.update(N-V,N,0,-(m-cnt),0,N);
    cnt=0;
    rep(i,N){
        if(sg.query(i)<0) cnt++;
        // cerr<<sg.query(i)<<" ";
    }
    if(cnt<p){
        return true;
    }
    else return false;
}




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;

    cin>>n>>m>>v>>p;
    rep(i,n) cin>>a[i];
    sort(a,a+n);
    reverse(a,a+n);
    ll left=0,right=n-1;
    if(ok(n-1)){
        cout<<n<<endl;
        // cerr<<"FJl"<<endl;
        return 0;
    }
    while(right-left>1){
        ll mid=(left+right)/2;
        // cerr<<mid<<"$";;
        if(ok(mid)){
            left=mid;
            // cerr<<"YES"<<endl;
        }
        else right=mid;
    }
    cout<<left+1<<endl;
    return 0;
}