#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#include "ricehub.h"
int f(int md , signed x[] , int r , int b){
vector<int> v;
for (int i = 0 ; i<r ; i++){
v.pb(abs(md - x[i]));
}
sort(v.begin() , v.end());
int ans =0 , sum = 0;;
for (int i = 0 ; i<r ; i++){
if (sum + x[i] <= b) {sum+=x[i]; ans++;}
else break;
}
return ans;
}
signed besthub(signed R, signed L, signed X[], long long B)
{
int l = 1 , r = L , m1 , m2;
int ans = 0 ;
// for (int i = 1 ; i<=L ; i++) cout << f(i , X , R , B) << ' ';
while(r-l > 2){
m1 = l + (l+r)/3;
m2 = r - (l+r)/3;
int cnt = 0 ;
int a = f(m1 , X , R , B) , b = f(m2 , X , R , B);
if (a < b) l = m1;
else r = m2;
}
int mx = 0 ;
for (int i = l ; i<=r ; i++) mx = max(mx , f(i , X , R , B));
return mx;
}
// signed main(){
// int r , l , b;
// cin >> r >> l >> b;
// signed x[r];
// for (int i = 0 ; i < r ; i++) cin >> x[i];
// cout << besthub(r , l , x , b);
// }