#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,k;

int main()
{
    cin>>n>>k;
    int sum = 0;
    priority_queue<ll,vector<ll>,greater<ll>>pq;
    for(int i=1;i<=n;i++)
    {
        ll x;
        cin>>x;
        pq.push(x);
    }
    int ans = 0;
    while(sum<=k)
    {
        ans++;
        ll x = pq.top();
        pq.pop();
        sum+=x;
        x *= 2;
        pq.push(x);
    }
    ans--;
    cout<<ans<<'\n';

    return 0;
}

写个小根堆贪心即可,因为每次放入是×2的结果,所以时间复杂度是不会超的