#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <cstring>
#include <stack>
#include <map>
#include <queue>
#include <cmath>

#define fir first
#define sec second

using namespace std;

const int N = 100010, INF = 1e7;

typedef pair<int, int> PII;
typedef long long LL;

void solve() {
    int n, w;
    cin >> n >> w;
    
    map<int, int> mp;
    for (int i = 0; i < n; i ++ ) {
        int x;
        cin >> x;
        
        mp[x] ++;
    }
    
    int cnt = 0;
    int tmp = 1;
    while (tmp * 2 <= w)
        tmp *= 2;
    
    while (tmp) {
        if (mp.count(tmp) == 0 || mp[tmp] == 0) {
            tmp /= 2;
            continue;
        }
        
        cnt ++;
        int last = w;
        int k = tmp;
        
        while (last > 0 && k > 0) {
            while (last >= k && mp[k] > 0) {
                last -= k;
                mp[k] --;
            }
            
            k /= 2;
        }
        
        if (mp[tmp] == 0)
            tmp /= 2;
    }
    
    cout << cnt << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int T = 1;
    cin >> T;
    
    while (T -- )
        solve();
    
    return 0;
}