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

int main() {
    int n;
    ll k;
    scanf("%d %lld", &n, &k);
    priority_queue<ll, vector<ll>, greater<ll>> pq;
    for (int i = 0; i < n; ++i) {
        ll a;
        scanf("%lld", &a);
        pq.push(a);
    }
    ll sum = 0;
    int days = 0;
    while (!pq.empty()) {
        ll x = pq.top();
        pq.pop();
        if (sum + x > k) break;
        sum += x;
        ++days;
        pq.push(x * 2);
    }
    printf("%d\n", days);
    return 0;
}