#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n,m,v,p ;
	cin >> n >> m >> v >> p ;
	vll a(n) ;
	for(auto &i:a) cin >> i ;
	sort(all(a)) ;
	reverse(all(a)) ;
	ll l,r,mid ;
	l = p-1 ;
	r = n ;
	while(l+1<r){
		mid = (l+r)/2 ;
		if(a.at(p-1)>a.at(mid)+m){
			r = mid ;
			continue ;
		}
		ll cnt = 0 ;
		cnt += m*(p-1+n-mid) ;
		for(int i=p-1;i<mid;i++) cnt += a.at(mid)+m-a.at(i) ;
		if(cnt>=m*v) l = mid ;
		else r = mid ;
	}
	cout << l+1 << endl ;
}

#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
#define ll long long int
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define rep(i,l,r) for(i=l;i<r;i++)
#define ld long double
#define ff first
#define ss second
#define pli pair<ll,int>
#define pi 3.1415926535897932384626433832
int main()
{
    io;
    int i,n;
    ll x;
    cin>>n>>x;
    vector<ll>b(n);
    vector<ll>l(n);
    vector<ll>u(n);
    vector<pli>p(n);
    vector<ll>pre(n);
    ll d=0;
    rep(i,0,n)
    {
    cin>>b[i]>>l[i]>>u[i];
    d-=l[i]*b[i];
    p[i]=mp(l[i]*b[i]+u[i]*(x-b[i]),i);
    }
    ll beg=0;
    ll r=n*x;
    //cout<<r;
    sort(p.begin(),p.end(),greater<pli>());
    pre[0]=p[0].ff;
    rep(i,1,n)
    pre[i]=pre[i-1]+p[i].ff;
    while(beg<=r)
    {
        //cout<<1;
        ll mid=(beg+r)/2;
        ll q=mid/x;
        ll rem=mid%x;
        ll ans;
        ll maxi=d;
        if(q==n)
            maxi=0;
        else
        rep(i,0,n)
        {
            ans=d;
            if(q!=0)
            {
            if(i<q)
                ans+=pre[q]-p[i].ff;
            else
                ans+=pre[q-1];
            }
            ans+=min(b[p[i].ss],rem)*l[p[i].ss]+max(rem-b[p[i].ss],0ll)*u[p[i].ss];
            maxi=max(ans,maxi);
        }
        if(maxi>=0)
        r=mid-1;
        else
        beg=mid+1;
    }
    cout<<beg;
    return 0;
}
