#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
#define fio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
using namespace std;
vector<int> tree[600000];
vector<int> sum_tree[600000];
vector<int> Time;
vector<pair<int, int> > v;
int n, m;
int cnt = 0;
void Merge(vector<int> &v1, vector<int> &v2, vector<int> &v3)
{
	int p1 = 0, p2 = 0;
	while(p1<v2.size() && p2<v3.size())
	{
		if(v2[p1] < v3[p2])
			v1.pb(v2[p1++]);
		else
			v1.pb(v3[p2++]);
	}
	while(p1<v2.size())
		v1.pb(v2[p1++]);
	while(p2<v3.size())
		v1.pb(v3[p2++]);
}
void build(int start, int end, int node)
{
	cnt++;
	if(start == end)
	{
		tree[node].pb(v[start].s);
		sum_tree[node].pb(v[start].f);
		return ;
	}
	int mid = (start+end)/2;
	build(start, mid, 2*node);
	build(mid+1, end, 2*node+1);
	Merge(tree[node], tree[2*node], tree[2*node+1]);
	for(int i=0;i<tree[node].size();i++)
	{
		assert(tree[node][i]>=0 && tree[node][i]<n);
		sum_tree[node].pb(Time[tree[node][i]]);
		assert(Time[tree[node][i]]<=m);
	}
	for(int i=1;i<sum_tree[node].size();i++)
		sum_tree[node][i] += sum_tree[node][i-1];

}
int query(int start, int end, int node, int l, int r, int k, int sum)
{
	//cout<<start<<" "<<end<<"\n";
	if(start == end)
		return sum + Time[tree[node][0]];
	int mid = (start+end)/2;
	int high = upper_bound(tree[2*node].begin(), tree[2*node].end(), r)-tree[2*node].begin();
	int low = lower_bound(tree[2*node].begin(), tree[2*node].end(), l)-tree[2*node].begin();
	int M = high-low;
	if(M>=k){
		return query(start, mid, 2*node, l, r, k, sum);
	}
	int right = high-1>=0?sum_tree[2*node][high-1]:0;
	int left = low-1>=0?sum_tree[2*node][low-1]:0;
	return query(mid+1, end, 2*node+1, l, r, k-M, sum+right-left);
}

int find_remain(int r, int remain)
{
	//cout<<r<<" i\n";
	int high = r, low = 1, mid, ans=0;
	while(low<=high)
	{
		int mid = (low+high)/2;
		int s = query(0, n-1, 1, 0, r-1, mid, 0);
		//cout<<r<<" "<<mid<<" "<<s<<"\n";
		if(s<=remain)
		{
			ans = mid;
			low = mid+1;
		}
		else
			high = mid-1;
	}
	return ans;

}
int main()
{

	fio
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		int t;
		cin>>t;
		Time.pb(t);
		v.pb({t, i});
	}
	sort(v.begin(), v.end());
	//cout<<"yay\n";
	build(0, n-1, 1);
	//cout<<"cat\n";
	for(int i=0;i<n;i++){
		int rem;
		//cin>>rem;
		cout<<i-find_remain(i, m-Time[i])<<" ";
		//cout<<query(0, n-1, 1, 0, i, rem, 0)<<"\n";
	}
}


#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
#define fio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
using namespace std;
vector<int> tree[600000];
vector<int> sum_tree[600000];
vector<int> Time;
vector<pair<int, int> > v;
int n, m;
int cnt = 0;
void Merge(vector<int> &v1, vector<int> &v2, vector<int> &v3)
{
	int p1 = 0, p2 = 0;
	while(p1<v2.size() && p2<v3.size())
	{
		if(v2[p1] < v3[p2])
			v1.pb(v2[p1++]);
		else
			v1.pb(v3[p2++]);
	}
	while(p1<v2.size())
		v1.pb(v2[p1++]);
	while(p2<v3.size())
		v1.pb(v3[p2++]);
}
void build(int start, int end, int node)
{
	cnt++;
	//cout<<node<<" "<<start<<" "<<end<<" node\n";
	if(start == end)
	{
		tree[node].pb(v[start].s);
		sum_tree[node].pb(v[start].f);
		return ;
	}
	int mid = (start+end)/2;
	build(start, mid, 2*node);
	build(mid+1, end, 2*node+1);
	Merge(tree[node], tree[2*node], tree[2*node+1]);
	for(int i=0;i<tree[node].size();i++)
	{
		sum_tree[node].pb(Time[tree[node][i]]);
	}
	for(int i=1;i<sum_tree[node].size();i++)
		sum_tree[node][i] += sum_tree[node][i-1];

}
int query(int start, int end, int node, int l, int r, int k, int remain)
{
	if(l>r)
		return 0;
	//cout<<node<<"\n";
	if(start == end)
	{
		if(l<=tree[node][0] && r>=tree[node][0])
		{
			if(Time[tree[node][0]] <= remain)
				return k+1;
		}
		return k;
	}
	int mid = (start+end)/2;
	int high = upper_bound(tree[2*node].begin(), tree[2*node].end(), r)-tree[2*node].begin();
	int low = lower_bound(tree[2*node].begin(), tree[2*node].end(), l)-tree[2*node].begin();
	int num = upper_bound(sum_tree[2*node].begin()+low, sum_tree[2*node].begin()+high, remain+(low-1>=0?sum_tree[2*node][low-1]:0))-sum_tree[2*node].begin()-low;
	if(num >= high-low){
		int left = low-1>=0?sum_tree[2*node][low-1]:0;
		int right = num+low-1>=0?sum_tree[2*node][num+low-1]:0;
		return query(mid+1, end, 2*node+1, l, r, k+num, remain-(right-left));
	}
	return query(start, mid, 2*node, l, r, k, remain);
}

int find_remain(int r, int remain)
{
	return query(0, n-1, 1, 0, r-1, 0, remain);

}
int main()
{
	fio
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		int t;
		cin>>t;

		Time.pb(t);
		v.pb({t, i});
	}
	sort(v.begin(), v.end());
	//cout<<"yay\n";
	build(0, n-1, 1);
	//cout<<"haha\n";
	for(int i=0;i<n;i++){
		int rem;
		//cin>>rem;
		int x = find_remain(i, m-Time[i]);
		//cout<<i<<" "<<x<<"\n";
		//cout<<query(0, n-1, 1, 0, i, rem, 0)<<"\n";
		cout<<i-x<<" ";
	}
}


#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
#define fio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
using namespace std;
vector<int> tree[600000];
vector<int> sum_tree[600000];
vector<int> Time;
vector<pair<int, int> > v;
int n, m;
int cnt = 0;
void Merge(vector<int> &v1, vector<int> &v2, vector<int> &v3)
{
	int p1 = 0, p2 = 0;
	while(p1<v2.size() && p2<v3.size())
	{
		if(v2[p1] < v3[p2])
			v1.pb(v2[p1++]);
		else
			v1.pb(v3[p2++]);
	}
	while(p1<v2.size())
		v1.pb(v2[p1++]);
	while(p2<v3.size())
		v1.pb(v3[p2++]);
}
void build(int start, int end, int node)
{
	cnt++;
	if(start == end)
	{
		tree[node].pb(v[start].s);
		sum_tree[node].pb(v[start].f);
		return ;
	}
	int mid = (start+end)/2;
	build(start, mid, 2*node);
	build(mid+1, end, 2*node+1);
	Merge(tree[node], tree[2*node], tree[2*node+1]);
	for(int i=0;i<tree[node].size();i++)
	{
		assert(tree[node][i]>=0 && tree[node][i]<n);
		sum_tree[node].pb(Time[tree[node][i]]);
		assert(Time[tree[node][i]]<=m);
		if(i!=0)
			sum_tree[node][i] += sum_tree[node][i-1];
	}

}
int query(int start, int end, int node, int l, int r, int k, int sum)
{
	//cout<<start<<" "<<end<<"\n";
	if(start == end)
		return sum + Time[tree[node][0]];
	int mid = (start+end)/2;
	int high = upper_bound(tree[2*node].begin(), tree[2*node].end(), r)-tree[2*node].begin();
	int low = lower_bound(tree[2*node].begin(), tree[2*node].end(), l)-tree[2*node].begin();
	int M = high-low;
	if(M>=k){
		return query(start, mid, 2*node, l, r, k, sum);
	}
	int right = sum_tree[2*node][high-1];
	int left = low-1>=0?sum_tree[2*node][low-1]:0;
	return query(mid+1, end, 2*node+1, l, r, k-M, sum+right-left);
}

int find_remain(int r, int remain)
{
	//cout<<r<<" i\n";
	int high = r, low = 1, mid, ans=0;
	while(low<=high)
	{
		int mid = (low+high)/2;
		int s = query(0, n-1, 1, 0, r-1, mid, 0);
		//cout<<r<<" "<<mid<<" "<<s<<"\n";
		if(s<=remain)
		{
			ans = mid;
			low = mid+1;
		}
		else
			high = mid-1;
	}
	return ans;

}
int main()
{

	//fio
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		int t;
		cin>>t;
		Time.pb(t);
		v.pb({t, i});
	}
	sort(v.begin(), v.end());
	//cout<<"yay\n";
	build(0, n-1, 1);
	//cout<<"cat\n";
	for(int i=0;i<n;i++){
		int rem;
		//cin>>rem;
		cout<<i-find_remain(i, m-Time[i])<<" ";
		//cout<<query(0, n-1, 1, 0, i, rem, 0)<<"\n";
	}
}


#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
#define fio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
using namespace std;
vector<int> tree[600000];
vector<int> sum_tree[600000];
vector<int> Time;
vector<pair<int, int> > v;
int n;
int cnt = 0;
void Merge(vector<int> &v1, vector<int> &v2, vector<int> &v3)
{
	int p1 = 0, p2 = 0;
	while(p1<v2.size() && p2<v3.size())
	{
		if(v2[p1] < v3[p2])
			v1.pb(v2[p1++]);
		else
			v1.pb(v3[p2++]);
	}
	while(p1<v2.size())
		v1.pb(v2[p1++]);
	while(p2<v3.size())
		v1.pb(v3[p2++]);
}
void build(int start, int end, int node)
{
	cnt++;
	if(start == end)
	{
		tree[node].pb(v[start].s);
		sum_tree[node].pb(v[start].f);
		return ;
	}
	int mid = (start+end)/2;
	build(start, mid, 2*node);
	build(mid+1, end, 2*node+1);
	Merge(tree[node], tree[2*node], tree[2*node+1]);
	for(int i=0;i<tree[node].size();i++)
	{
		sum_tree[node].pb(Time[tree[node][i]]);
		if(i!=0)
			sum_tree[node][i] += sum_tree[node][i-1];
	}

}
int query(int start, int end, int node, int l, int r, int k, int sum)
{
	//cout<<start<<" "<<end<<"\n";
	if(start == end)
		return sum + Time[tree[node][0]];
	int mid = (start+end)/2;
	int high = upper_bound(tree[2*node].begin(), tree[2*node].end(), r)-tree[2*node].begin();
	int low = lower_bound(tree[2*node].begin(), tree[2*node].end(), l)-tree[2*node].begin();
	int M = high-low;
	if(M>=k){
		return query(start, mid, 2*node, l, r, k, sum);
	}
	int right = sum_tree[2*node][high-1];
	int left = low-1>=0?sum_tree[2*node][low-1]:0;
	return query(mid+1, end, 2*node+1, l, r, k-M, sum+right-left);
}

int find_remain(int r, int remain)
{
	//cout<<r<<" i\n";
	int high = r, low = 1, mid, ans=0;
	while(low<=high)
	{
		int mid = (low+high)/2;
		int s = query(0, n-1, 1, 0, r-1, mid, 0);
		//cout<<r<<" "<<mid<<" "<<s<<"\n";
		if(s<=remain)
		{
			ans = mid;
			low = mid+1;
		}
		else
			high = mid-1;
	}
	return ans;

}
int main()
{

	fio
	int m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		int t;
		cin>>t;
		Time.pb(t);
		v.pb({t, i});
	}
	sort(v.begin(), v.end());
	//cout<<"yay\n";
	build(0, n-1, 1);
	//cout<<"cat\n";
	for(int i=0;i<n;i++){
		cout<<i-find_remain(i, m-Time[i])<<" ";
		//cout<<query(0, n-1, 1, 0, i, rem, 0)<<"\n";
	}
}


#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
#define fio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
using namespace std;
vector<int> tree[600000];
vector<int> sum_tree[600000];
vector<int> Time;
vector<pair<int, int> > v;
int n;
int cnt = 0;
void Merge(vector<int> &v1, vector<int> &v2, vector<int> &v3)
{
	int p1 = 0, p2 = 0;
	while(p1<v2.size() && p2<v3.size())
	{
		if(v2[p1] < v3[p2])
			v1.pb(v2[p1++]);
		else
			v1.pb(v3[p2++]);
	}
	while(p1<v2.size())
		v1.pb(v2[p1++]);
	while(p2<v3.size())
		v1.pb(v3[p2++]);
}
void build(int start, int end, int node)
{
	cnt++;
	if(start == end)
	{
		tree[node].pb(v[start].s);
		sum_tree[node].pb(v[start].f);
		return ;
	}
	int mid = (start+end)/2;
	build(start, mid, 2*node);
	build(mid+1, end, 2*node+1);
	Merge(tree[node], tree[2*node], tree[2*node+1]);
	for(int i=0;i<tree[node].size();i++)
	{
		sum_tree[node].pb(Time[tree[node][i]]);
		if(i!=0)
			sum_tree[node][i] += sum_tree[node][i-1];
	}

}
int query(int start, int end, int node, int l, int r, int k, int sum)
{
	//cout<<start<<" "<<end<<"\n";
	if(start == end)
		return sum + Time[tree[node][0]];
	int mid = (start+end)/2;
	int high = upper_bound(tree[2*node].begin(), tree[2*node].end(), r)-tree[2*node].begin();
	int low = lower_bound(tree[2*node].begin(), tree[2*node].end(), l)-tree[2*node].begin();
	int M = high-low;
	if(M>=k){
		return query(start, mid, 2*node, l, r, k, sum);
	}
	int right = sum_tree[2*node][high-1];
	int left = low-1>=0?sum_tree[2*node][low-1]:0;
	return query(mid+1, end, 2*node+1, l, r, k-M, sum+right-left);
}

int find_remain(int r, int remain)
{
	//cout<<r<<" i\n";
	int high = r, low = 1, mid, ans=0;
	while(low<=high)
	{
		int mid = (low+high)/2;
		int s = query(0, n-1, 1, 0, r-1, mid, 0);
		//cout<<r<<" "<<mid<<" "<<s<<"\n";
		if(s<=remain)
		{
			ans = mid;
			low = mid+1;
		}
		else
			high = mid-1;
	}
	return ans;

}
int main()
{

	//fio
	int m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		int t;
		cin>>t;
		Time.pb(t);
		v.pb({t, i});
	}
	sort(v.begin(), v.end());
	//cout<<"yay\n";
	build(0, n-1, 1);
	//cout<<"cat\n";
	for(int i=0;i<n;i++){
		int rem;
		//cin>>rem;
		cout<<i-find_remain(i, m-Time[i])<<" ";
		//cout<<query(0, n-1, 1, 0, i, rem, 0)<<"\n";
	}
}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimization ("O3")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
//#define push_back emplace_back
//#define push emplace
//#define insert emplace
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;

}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,m;
	cin>>n>>m;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	multiset<int>s,s1;
	int x=0,y=0;
	for(int i=0;i<n;i++){
		y+=a[i];
		while(!s1.empty()){
			if(y+*s1.begin()<=m){
				y+=*s1.begin();
				s.insert(*s1.begin());
				s1.erase(*s1.begin());
			}
			else break;
		}
		while(y>m){
			auto it=s.end();
			it--;
			y-=*it;
			s1.insert(*it);
			s.erase(it);
			x++;
		}
		s.insert(a[i]);
		cout<<x<<" ";
	}
	return 0;

}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimization ("O3")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
//#define push_back emplace_back
//#define push emplace
//#define insert emplace
//#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;

}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,m;
	cin>>n>>m;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	multiset<int>s,s1;
	int x=0,y=0;
	for(int i=0;i<n;i++){
		y+=a[i];
		while(!s1.empty()){
			if(y+*s1.begin()<=m){
				x--;
				y+=(*s1.begin());
				s.insert(*s1.begin());
				s1.erase(s1.begin());
			}
			else break;
		}
		while(y>m){
			auto it=s.end();
			it--;
			y-=*it;
			s1.insert(*it);
			s.erase(it);
			x++;
		}
		while(!s1.empty()){
			if(y+*s1.begin()<=m){
				x--;
				y+=(*s1.begin());
				s.insert(*s1.begin());
				s1.erase(s1.begin());
			}
			else break;
		}
		s.insert(a[i]);
		cout<<x<<" ";
	}
	return 0;

}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimization ("O3")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
//#define push_back emplace_back
//#define push emplace
//#define insert emplace
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;

}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,m;
	cin>>n>>m;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	multiset<int>s;
	int x=0,y=0;
	for(int i=0;i<n;i++){
		y+=a[i];
		while(y>m){
			auto it=s.end();
			it--;
			y-=*it;
			s.erase(it);
			x++;
		}
		s.insert(a[i]);
		cout<<x<<" ";
	}
	return 0;

}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimization ("O3")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
//#define push_back emplace_back
//#define push emplace
//#define insert emplace
//#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;

}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,m;
	cin>>n>>m;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	multiset<int>s,s1;
	int x=0,y=0;
	for(int i=0;i<n;i++){
		y+=a[i];
		while(!s1.empty()){
			if(y+*s1.begin()<=m){
				x--;
				y+=*s1.begin();
				s.insert(*s1.begin());
				s1.erase(s1.begin());
			}
			else break;
		}
		while(y>m){
			auto it=s.end();
			it--;
			y-=*it;
			s1.insert(*it);
			s.erase(it);
			x++;
		}
		s.insert(a[i]);
		cout<<x<<" ";
	}
	return 0;

}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimization ("O3")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
//#define push_back emplace_back
//#define push emplace
//#define insert emplace
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;

}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,m;
	cin>>n>>m;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	multiset<int>s,s1;
	int x=0,y=0;
	for(int i=0;i<n;i++){
		y+=a[i];
		while(!s1.empty()){
			if(y+*s1.begin()<=m){
				x--;
				y+=*s1.begin();
				s.insert(*s1.begin());
				s1.erase(*s1.begin());
			}
			else break;
		}
		while(y>m){
			auto it=s.end();
			it--;
			y-=*it;
			s1.insert(*it);
			s.erase(it);
			x++;
		}
		s.insert(a[i]);
		cout<<x<<" ";
	}
	return 0;

}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimization ("O3")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
//#define push_back emplace_back
//#define push emplace
//#define insert emplace
//#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;

}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,m;
	cin>>n>>m;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	multiset<int>s,s1;
	int x=0,y=0;
	for(int i=0;i<n;i++){
		y+=a[i];
		while(!s1.empty()){
			if(y+*s1.begin()<=m){
				x--;
				y+=(*s1.begin());
				s.insert(*s1.begin());
				s1.erase(s1.begin());
			}
			else break;
		}
		while(y>m){
			auto it=s.end();
			it--;
			y-=*it;
			s1.insert(*it);
			s.erase(it);
			x++;
		}
		while(1){
			if(s.empty()||s1.empty())break;
			auto it1=s.end(),it2=s1.begin();
			it1--;
			if(*it1>*it2){
				y-=*it1;
				y+=*it2;
				int k=*it1,l=*it2;
				s.erase(it1);
				s1.erase(it2);
				s1.insert(k);
				s.insert(l);
			}
			else break;
		}
		while(!s1.empty()){
			if(y+*s1.begin()<=m){
				x--;
				y+=(*s1.begin());
				s.insert(*s1.begin());
				s1.erase(s1.begin());
			}
			else break;
		}
		s.insert(a[i]);
		cout<<x<<" ";
	}
	return 0;

}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int M = 1e9+7 ;

int cnt[102];
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n , M ;
    cin >> n >>  M ;

    // vector<int> A (n);

    // for(int i = 0 ; i < n  ; ++i){
    //     cin >> A[i];
    // }

    // vector<int> ans (n);

    for(int j = 0 ; j < n ; ++j){

        int x;
        cin >> x;

        int m = M -x ;
        int taken= 1 ;

        int  sum = 0 ;

        for(int i = 1 ; i <= 100; ++i ){

            if (sum > m){
                break;
            }
            int k = min ( cnt[i] , (m -sum)/i );

            sum += k*i;
            taken += k;

            if (cnt[i] > k ){
                break;
            }
            // assert(sum <=  m);
        }

        cnt[x]++;

        cout << j + 1 - taken << " ";

    }

    cout << "\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int M = 1e9+7 ;

int cnt[102];
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n , M ;
    cin >> n >>  M ;

    // vector<int> A (n);

    // for(int i = 0 ; i < n  ; ++i){
    //     cin >> A[i];
    // }

    // vector<int> ans (n);

    for(int j = 0 ; j < n ; ++j){

        int x;
        cin >> x;

        int m = M -x ;
        int taken= 1 ;

        int  sum = 0 ;

        for(int i = 1 ; i <= 100; ++i ){

            if (sum > m){
                break;
            }
            int k = min ( cnt[i] , (m -sum)/i );

            sum += k*i;
            taken += k;

            // assert(sum <=  m);
        }

        cnt[x]++;

        cout << j + 1 - taken << " ";

    }

    cout << "\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int M = 1e9+7 ;

int cnt[102];
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n , M ;
    cin >> n >>  M ;

    // vector<int> A (n);

    // for(int i = 0 ; i < n  ; ++i){
    //     cin >> A[i];
    // }

    // vector<int> ans (n);

    for(int j = 0 ; j < n ; ++j){

        int x;
        cin >> x;

        int m = M -x ;
        int taken= 1 ;

        int  sum = 0 ;

        for(int i = 1 ; i <= 100; ++i ){

            if (sum > m){
                break;
            }
            int k = min ( cnt[i] , (m -sum)/i );

            sum += k*i;
            taken += k;

            assert(sum <=  m);
        }

        cnt[x]++;

        cout << j + 1 - taken << " ";

    }

    cout << "\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int M = 1e9+7 ;

int cnt[102];
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n , M ;
    cin >> n >>  M ;

    // vector<int> A (n);

    // for(int i = 0 ; i < n  ; ++i){
    //     cin >> A[i];
    // }

    // vector<int> ans (n);

    for(int j = 0 ; j < n ; ++j){

        int x;
        cin >> x;

        int m = M -x ;
        int taken= 1 ;

        int  sum = 0 ;

        for(int i = 1 ; i <= 100; ++i ){

            if (sum > m){
                break;
            }
            int k = min ( cnt[i] , (m -sum)/i );

            if (cnt[i]){
                if (k == 0){
                    break ;
                }
            }
            sum += k*i;
            taken += k;

            // assert(sum <=  m);
        }

        cnt[x]++;

        cout << j + 1 - taken << " ";

    }

    cout << "\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int M = 1e9+7 ;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n , M ;
    cin >> n >>  M ;

    // vector<int> A (n);

    // for(int i = 0 ; i < n  ; ++i){
    //     cin >> A[i];
    // }

    vector<ll> cnt (102);

    // vector<int> ans (n);

    for(int j = 0 ; j < n ; ++j){

        int x;
        cin >> x;

        int m = M -x ;
        int taken= 1 ;

        ll sum = 0 ;

        for(int i = 1 ; i <= 100; ++i ){

            if (sum > m){
                break;
            }
            ll k = min ( cnt[i] , (m -sum)/i );

            sum += k*i;
            taken += k;

            assert(sum <=  m);
        }

        cnt[x]++;

        cout << j + 1 - taken << " ";

    }

    cout << "\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int M = 1e9+7 ;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n , M ;
    cin >> n >>  M ;

    vector<ll> A (n);

    for(int i = 0 ; i < n  ; ++i){
        cin >> A[i];
    }

    vector<ll> cnt (102);

    vector<int> ans (n);

    for(int j = 0 ; j < n ; ++j){

        int m = M - A[j] ;
        int taken= 1 ;

        ll sum = 0 ;

        for(int i = 1 ; i <= 100; ++i ){

            if (sum > m){
                break;
            }
            ll k = min ( cnt[i] , (m -sum)/i );

            sum += k*i;
            taken += k;

            assert(sum <=  m);
        }

        cnt[A[j]]++;

        ans[j]= j + 1 - taken;

    }

    for(int i : ans){
        cout << i << " ";
    }
    cout << "\n";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
// Header files, namespaces,
// macros as defined above
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<long long, null_type,less<long long>, rb_tree_tag,tree_order_statistics_node_update>
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long n,m;
    cin>>n>>m;
    vector<long long> v,p;

    for(long long i=0;i<n;i++)
    {
        long long a;
        cin>>a;
        v.push_back(a);
        p.push_back(a);
    }
long long time=0;
multiset<long long,greater<long long>> s;
//long long store=0;
    for(long long i=0;i<n;i++)
    {

        time+=v[i];
        if(time<=m)
        {
            cout<<"0 ";
        }else
        {
            long long c=0;
            long long sum=0;
        for(long long i : s)
        {sum+=i;
        c++;
            if(time-sum<=m)
            {
                cout<<c<<" ";
                break;
            }
        }

        }
 s.insert(v[i]);

    }
}


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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long n,m;
    cin>>n>>m;
    vector<int> v,p;

    unordered_map<long long,vector<int>> sum;
    long long s=0,start=1000000;

    for(long long i=0;i<n;i++)
    {
        int a;
        cin>>a;
        s+=a;
        if(s>m&&start==1000000)
        {
            start=i;
        }
        v.push_back(a);
        p.push_back(a);
    }
//    cout<<start;
if(start!=1000000)
    for(long long i=start;i<n;i++)
    {

        sort(p.begin(),p.begin()+i);
      //  for(long long x:p)
      //  cout<<x<<" ";
      //  cout<<endl;
        long store=0;
        for(long long j=i-1;j>0;j--)
        {
            store+=p[j];
        sum[i].push_back(store);

        }
    }
    long long store=0;

    for(long long i=0;i<n;i++)
    {

        store+=v[i];
        if(store<=m)
        {
            cout<<"0 ";
            continue;
        }
        auto it=lower_bound(sum[i].begin(),sum[i].end(),store-m);

        cout<<(it-sum[i].begin())+1<<" ";
    }

}


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

int main()
{
    long long n,m;
    cin>>n>>m;

    vector<long long> v;

    for(long long i=0;i<n;i++)
    {
        long long a;
        cin>>a;
        v.push_back(a);
    }
long long sum=0;
multiset<long long,greater<long long>> s;
for(long i=0;i<n;i++)
{
      sum+=v[i];
    //cout<<sum<<" ";

    if(sum<=m){
        cout<<"0 ";
    }else
    {
        long long temp=0;
        long long t=1;
        for(long long x: s)
        {
            temp+=x;
            if(sum-temp<=m)
            {
                cout<<t<<" ";
                break;
            }
        t++;
        }
    }

 s.insert(v[i]);

}
}


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

int main()
{
    long long n,m;
    cin>>n>>m;

    vector<long long> v;

    for(long long i=0;i<n;i++)
    {
        long long a;
        cin>>a;
        v.push_back(a);
    }
long long sum=0;
int c[101]={};
//multiset<long long,greater<long long>> s;
for(long i=0;i<n;i++)
{
    sum+=v[i];

    long more=sum-m;
    long ans=0;

    if(more>0)
    {
        for(int j=100;j>0;j--)
        {
            int val=c[j]*j;

            if(val>=more)
            {
                ans+=ceil((double)(more/(double)j));
                break;
            }
            ans+=c[j];
            more-=val;
        }

    }

    cout<<ans<<" ";
    c[v[i]]++;

}
}


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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long n,m;
    cin>>n>>m;
    vector<int> v,p;

    vector<vector<int>> sum(1000000);
    long long s=0,start=-1;

    for(long long i=0;i<n;i++)
    {
        int a;
        cin>>a;
        s+=a;
        if(s>m&&start==-1)
        {
            start=i;
        }
        v.push_back(a);
        p.push_back(a);
    }
//    cout<<start;
    for(long long i=start;i<n;i++)
    {

        sort(p.begin(),p.begin()+i);
      //  for(long long x:p)
      //  cout<<x<<" ";
      //  cout<<endl;
        long store=0;
        for(long long j=i-1;j>0;j--)
        {
            store+=p[j];
        sum[i].push_back(store);

        }
    }
    long long store=0;

    for(long long i=0;i<start;i++)
    {
        cout<<"0 ";
        store+=v[i];
    }
    for(long long i=start;i<n;i++)
    {
        store+=v[i];
        auto it=lower_bound(sum[i].begin(),sum[i].end(),store-m);

        cout<<(it-sum[i].begin())+1<<" ";
    }

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,m;
    cin>>n>>m;
    vector<long long> v,p;

    for(long long i=0;i<n;i++)
    {
        long long a;
        cin>>a;
        v.push_back(a);
        p.push_back(a);
    }
long long time=0;
    for(long long i=0;i<n;i++)
    {
        time+=v[i];
        if(time<=m)
        {
            cout<<"0 ";
        }else
        {
        long long timed=time;
        long ans=0;
        sort(p.begin(),p.begin()+i);
        for(long long j=i-1;j>=0;j--)
        {
            ans++;
            timed-=p[j];
            if(timed<=m)
        {
            cout<<ans<<" ";
            break;
        }

        }

        }

    }
}


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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long n,m;
    cin>>n>>m;
    vector<int> v,p;

    vector<vector<int>> sum(1000000);
    long long s=0,start=1000000;

    for(long long i=0;i<n;i++)
    {
        int a;
        cin>>a;
        s+=a;
        if(s>m&&start==1000000)
        {
            start=i;
        }
        v.push_back(a);
        p.push_back(a);
    }
//    cout<<start;
if(start!=1000000)
    for(long long i=start;i<n;i++)
    {

        sort(p.begin(),p.begin()+i);
      //  for(long long x:p)
      //  cout<<x<<" ";
      //  cout<<endl;
        long store=0;
        for(long long j=i-1;j>0;j--)
        {
            store+=p[j];
        sum[i].push_back(store);

        }
    }
    long long store=0;

    for(long long i=0;i<n;i++)
    {

        store+=v[i];
        if(store<=m)
        {
            cout<<"0 ";
            continue;
        }
        auto it=lower_bound(sum[i].begin(),sum[i].end(),store-m);

        cout<<(it-sum[i].begin())+1<<" ";
    }

}


#include <bits/stdc++.h>
#include <math.h>

#define io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i < b; i++)
#define enl "\n"
#define INF std::numeric_limits<ll>::max();

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ldb;
typedef vector<long long> vll;
typedef pair<long long,long long> pll;

ll greatestSubarraySum(ll array[], ll n);
ll powerrr(ll a, ll b);
void swap(ll *a, ll*b);
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
ll min(ll a, ll b);
ll max(ll a, ll b);

ll greatestSubarraySum(ll array[], ll n){

    ll best = 0, sum = 0;
    for (ll k = 0; k < n; k++) {
        sum = max(array[k],sum+array[k]);
        best = max(best,sum);
    }

    return best;
}

ll powerrr(ll a, ll b){

    ll ans = 1;

    for(ll i = 0; i < b; i++){

        ans*= a;

    }

    return ans;

}

void swap(ll *a, ll*b){

    ll temp = *a;
    *a = *b;
    *b = temp;

}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;

    return gcd(b%a, a);
}

ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a, b);
}

ll min(ll a, ll b){

    if(a < b)return a;
    return b;

}

ll max(ll a, ll b){

    if(a > b)return a;
    return b;

}

int main(){

    io

    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */

    ll n, m;

    cin>>n>>m;

    ll s[n];

    ll sum = 0;

    ll a[n];

    REP(i, 0, n){cin>>a[i];sum+=a[i];s[i] = sum;}

    REP(i, 0, n){

        ll ans=0;

        ll j = i-1;

        ll k = i-2;

        if(j > 0){

            ll key = a[j];

            while(k >= 0 && a[k]>key){

                a[k+1] = a[k];

                k--;
            }

            a[k+1] = key;

        }

        label:

        if(s[i]>m){

            ans++;
            s[i]-=a[j];
            j--;
            goto label;

        }

        cout<<ans<<" ";

    }

}


#include <bits/stdc++.h>
#include <math.h>

#define io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i < b; i++)
#define enl "\n"
#define INF std::numeric_limits<ll>::max();

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ldb;
typedef vector<long long> vll;
typedef pair<long long,long long> pll;

ll greatestSubarraySum(ll array[], ll n);
ll powerrr(ll a, ll b);
void swap(ll *a, ll*b);
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
ll min(ll a, ll b);
ll max(ll a, ll b);

ll greatestSubarraySum(ll array[], ll n){

    ll best = 0, sum = 0;
    for (ll k = 0; k < n; k++) {
        sum = max(array[k],sum+array[k]);
        best = max(best,sum);
    }

    return best;
}

ll powerrr(ll a, ll b){

    ll ans = 1;

    for(ll i = 0; i < b; i++){

        ans*= a;

    }

    return ans;

}

void swap(ll *a, ll*b){

    ll temp = *a;
    *a = *b;
    *b = temp;

}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;

    return gcd(b%a, a);
}

ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a, b);
}

ll min(ll a, ll b){

    if(a < b)return a;
    return b;

}

ll max(ll a, ll b){

    if(a > b)return a;
    return b;

}

int main(){

    io

    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */

    ll n, m;

    cin>>n>>m;

    ll s[n];

    ll sum = 0;

    ll a[n];

    vector<multiset<ll> > q;

    multiset<ll> b;

    REP(i, 0, n){cin>>a[i];sum+=a[i];s[i] = sum; if(i > 0) {b.insert(a[i-1]); q.push_back(b);}}

    /*REP(i, 1, n){

        auto itr = q[i-1].rbegin();

        while(itr != q[i-1].rend()){

            cout<<*itr<<" ";
            itr++;
        }

        cout<<enl;

    }*/

    REP(i, 0, n){

        if(s[i] <= m) {cout<<0<<" ";continue;}

        ll ans=0;

        auto itr = q[i-1].rbegin();

        while(itr != q[i-1].rend()){

            if(s[i] <= m) break;

            s[i] -= (*itr);

            itr++;

            ans++;

        }

        cout<<ans<<" ";

    }

}


#include <bits/stdc++.h>
#include <math.h>

#define io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i < b; i++)
#define enl "\n"
#define INF std::numeric_limits<ll>::max();

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ldb;
typedef vector<long long> vll;
typedef pair<long long,long long> pll;

ll greatestSubarraySum(ll array[], ll n);
ll powerrr(ll a, ll b);
void swap(ll *a, ll*b);
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
ll min(ll a, ll b);
ll max(ll a, ll b);

ll greatestSubarraySum(ll array[], ll n){

    ll best = 0, sum = 0;
    for (ll k = 0; k < n; k++) {
        sum = max(array[k],sum+array[k]);
        best = max(best,sum);
    }

    return best;
}

ll powerrr(ll a, ll b){

    ll ans = 1;

    for(ll i = 0; i < b; i++){

        ans*= a;

    }

    return ans;

}

void swap(ll *a, ll*b){

    ll temp = *a;
    *a = *b;
    *b = temp;

}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;

    return gcd(b%a, a);
}

ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a, b);
}

ll min(ll a, ll b){

    if(a < b)return a;
    return b;

}

ll max(ll a, ll b){

    if(a > b)return a;
    return b;

}

int main(){

    io

    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */

    ll n, m;

    cin>>n>>m;

    ll s[n];

    ll sum = 0;

    ll a[n];

    REP(i, 0, n){cin>>a[i];sum+=a[i];s[i] = sum;}

    REP(i, 0, n){

        ll ans=0;

        sort(a, a+i);

        ll j = i-1;

        label:

        if(s[i]>m){

            ans++;
            s[i]-=a[j];
            j--;
            goto label;

        }

        cout<<ans<<" ";

    }

}


#include <bits/stdc++.h>
#include <math.h>

#define io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i < b; i++)
#define enl "\n"
#define INF std::numeric_limits<ll>::max();

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ldb;
typedef vector<long long> vll;
typedef pair<long long,long long> pll;

ll greatestSubarraySum(ll array[], ll n);
ll powerrr(ll a, ll b);
void swap(ll *a, ll*b);
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
ll min(ll a, ll b);
ll max(ll a, ll b);

ll greatestSubarraySum(ll array[], ll n){

    ll best = 0, sum = 0;
    for (ll k = 0; k < n; k++) {
        sum = max(array[k],sum+array[k]);
        best = max(best,sum);
    }

    return best;
}

ll powerrr(ll a, ll b){

    ll ans = 1;

    for(ll i = 0; i < b; i++){

        ans*= a;

    }

    return ans;

}

void swap(ll *a, ll*b){

    ll temp = *a;
    *a = *b;
    *b = temp;

}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;

    return gcd(b%a, a);
}

ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a, b);
}

ll min(ll a, ll b){

    if(a < b)return a;
    return b;

}

ll max(ll a, ll b){

    if(a > b)return a;
    return b;

}

int main(){

    io

    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */

    ll n, m;

    cin>>n>>m;

    ll s[n];

    ll sum = 0;

    ll a[n];

    multiset<ll> b;

    REP(i, 0, n){
        cin>>a[i];
        sum+=a[i];s[i] = sum;

        if(i > 0) {
            b.insert(a[i-1]);
        }

        if(sum<=m){cout<<0<<" ";continue;}

        auto itr = b.rbegin();

        ll ans = 0;

        while(itr != b.rend()){

            if(s[i]<=m)break;
            s[i]-=(*itr);
            ans++;

            itr++;

        }

        cout<<ans<<" ";

    }

    /*REP(i, 1, n){

        auto itr = q[i-1].rbegin();

        while(itr != q[i-1].rend()){

            cout<<*itr<<" ";
            itr++;
        }

        cout<<enl;

    }*/

}


#include <bits/stdc++.h>
#include <math.h>

#define io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i < b; i++)
#define enl "\n"
#define INF std::numeric_limits<ll>::max();

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ldb;
typedef vector<long long> vll;
typedef pair<long long,long long> pll;

ll greatestSubarraySum(ll array[], ll n);
ll powerrr(ll a, ll b);
void swap(ll *a, ll*b);
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
ll min(ll a, ll b);
ll max(ll a, ll b);

ll greatestSubarraySum(ll array[], ll n){

    ll best = 0, sum = 0;
    for (ll k = 0; k < n; k++) {
        sum = max(array[k],sum+array[k]);
        best = max(best,sum);
    }

    return best;
}

ll powerrr(ll a, ll b){

    ll ans = 1;

    for(ll i = 0; i < b; i++){

        ans*= a;

    }

    return ans;

}

void swap(ll *a, ll*b){

    ll temp = *a;
    *a = *b;
    *b = temp;

}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;

    return gcd(b%a, a);
}

ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a, b);
}

ll min(ll a, ll b){

    if(a < b)return a;
    return b;

}

ll max(ll a, ll b){

    if(a > b)return a;
    return b;

}

int main(){

    io

    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */

    ll n, m;

    cin>>n>>m;

    ll s[n];

    ll sum = 0;

    ll a[n];

    vector<multiset<ll> > q;

    multiset<ll> b;

    REP(i, 0, n){cin>>a[i];sum+=a[i];s[i] = sum; if(i > 0) {b.insert(a[i-1]); q.push_back(b);}}

    /*REP(i, 1, n){

        auto itr = q[i-1].rbegin();

        while(itr != q[i-1].rend()){

            cout<<*itr<<" ";
            itr++;
        }

        cout<<enl;

    }*/

    REP(i, 0, n){

        if(s[i] < m) {cout<<0<<" ";continue;}

        ll ans=0;

        auto itr = q[i-1].rbegin();

        while(itr != q[i-1].rend()){

            if(s[i] <= m) break;

            s[i] -= (*itr);

            itr++;

            ans++;

        }

        cout<<ans<<" ";

    }

}


#include <bits/stdc++.h>
#include <math.h>

#define io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i < b; i++)
#define enl "\n"
#define INF std::numeric_limits<ll>::max();

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ldb;
typedef vector<long long> vll;
typedef pair<long long,long long> pll;

ll greatestSubarraySum(ll array[], ll n);
ll powerrr(ll a, ll b);
void swap(ll *a, ll*b);
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
ll min(ll a, ll b);
ll max(ll a, ll b);

ll greatestSubarraySum(ll array[], ll n){

    ll best = 0, sum = 0;
    for (ll k = 0; k < n; k++) {
        sum = max(array[k],sum+array[k]);
        best = max(best,sum);
    }

    return best;
}

ll powerrr(ll a, ll b){

    ll ans = 1;

    for(ll i = 0; i < b; i++){

        ans*= a;

    }

    return ans;

}

void swap(ll *a, ll*b){

    ll temp = *a;
    *a = *b;
    *b = temp;

}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;

    return gcd(b%a, a);
}

ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a, b);
}

ll min(ll a, ll b){

    if(a < b)return a;
    return b;

}

ll max(ll a, ll b){

    if(a > b)return a;
    return b;

}

int main(){

    io

    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */

    ll n, m;

    cin>>n>>m;

    ll sum = 0;

    ll a[n];

    vll count(101, 0);

    multiset<ll> b;

    REP(i, 0, n){

        cin>>a[i];
        if(i>0)count[a[i-1]]++;
        sum+=a[i];
        ll k = sum;

        ll ans = 0;

        if(k < m){cout<<0<<" ";continue;}

        for(ll j = 100; j>0; j--){
            if(!count[j])continue;
            if(k - count[j]*j <= m){

                if((k-m)%j) {ans+=((k-m)/j + 1); break;}
                else {ans+=(k-m)/j; break;}

            }else {k-=(j*count[j]);ans+=count[j];}

        }

        cout<<ans<<" ";

    }

}


#define ll long long
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a[200009]={0};
    ll n,m,x,sum=0,sum2=0;
    int flag;
    multiset<ll>s;
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        flag=0;
        cin>>x;
        sum+=x;
        sum2=sum;
        if(sum2>m)
        {
            for(auto itr=prev(s.end(),1);itr!=prev(s.begin(),1),sum2>m;itr--)
            {
                // cout<<*itr<<" ";
                sum2=sum2-(*itr);
                flag++;
            }
        }
        s.insert(x);
        a[i]=flag;
    }
    for(int i=0;i<n;i++)
    cout<<a[i]<<" ";
    return 0;
}


#define ll long long
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a[200009]={0};
    ll n,m,x,sum=0,sum2=0,a1,ans;
    int flag;
    ll tim[101]={0};
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        flag=0;
        cin>>x;
        sum+=x;
        sum2=sum-m;
        if(sum2>0)
        {
            for(int i=100;i>=1;i--)
            {
                if(tim[i]>0){
                a1=tim[i];
                ans=sum2/i<=a1 ? sum2/i:a1;
                flag+=ans;
                sum2=sum2-(ans*i);
                a1=a1-ans;
                if(i>=sum2 && a1>0 && sum2>0)
                {flag++;break;}
                }
            }
        }
        tim[x]++;
        a[i]=flag;
    }
    for(int i=0;i<n;i++)
    cout<<a[i]<<" ";
    return 0;
}


#define ll long long
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a[200009]={0};
    ll n,m,x,sum=0,sum2=0,a1;
    int flag;
    map<ll,ll,greater<ll>>s;
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        flag=0;
        cin>>x;
        sum+=x;
        sum2=sum;
        if(sum2>m)
        {
            for(auto itr=s.begin();itr!=s.end(),sum2>m;itr++)
            {
                a1=itr->second;
                while(sum2>m && a1>0)
                {
                    sum2=sum2-itr->first;
                    flag++;
                    a1--;
                }
            }
        }
        s[x]++;
        a[i]=flag;
    }
    for(int i=0;i<n;i++)
    cout<<a[i]<<" ";
    return 0;
}


#define ll long long
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a[200009]={0};
    ll n,m,x,sum=0,sum2=0,a1;
    int flag;
    ll tim[101]={0};
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        flag=0;
        cin>>x;
        sum+=x;
        sum2=sum;
        if(sum2>m)
        {
            for(int i=100;i>=1;i--)
            {
                a1=tim[i];
                while(sum2>m && a1>0)
                {
                    sum2=sum2-i;
                    flag++;
                    a1--;
                }
            }
        }
        tim[x]++;
        a[i]=flag;
    }
    for(int i=0;i<n;i++)
    cout<<a[i]<<" ";
    return 0;
}


#define ll long long
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a[200009]={0};
    ll n,m,x,sum=0,sum2=0;
    int flag;
    multimap<ll,ll>s;
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        flag=0;
        cin>>x;
        sum+=x;
        sum2=sum;
        if(sum2>m)
        {
            for(auto itr=prev(s.end(),1);itr!=prev(s.begin(),1),sum2>m;itr--)
            {
                // cout<<*itr<<" ";
                sum2=sum2-(itr->first);
                flag++;
            }
        }
        s.insert({x,flag});
        a[i]=flag;
    }
    for(int i=0;i<n;i++)
    cout<<a[i]<<" ";
    return 0;
}


#define ll long long
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a[200009]={0};
    ll n,m,x,sum=0,sum2=0;
    int flag;
    ll tim[101]={0};
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        flag=0;
        cin>>x;
        sum+=x;
        sum2=sum-m;
        if(sum2>0)
        {
            for(int i=100;i>=1;i--)
            {
                if(tim[i]>0){
                if(i>=sum2)
                {flag++;break;}
                flag+=sum2/i<=tim[i] ? sum2/i:tim[i];
                sum2=sum2-(flag*i);
                }
            }
        }
        tim[x]++;
        a[i]=flag;
    }
    for(int i=0;i<n;i++)
    cout<<a[i]<<" ";
    return 0;
}


#define ll long long
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a[200009]={0};
    ll n,m,x,sum=0,sum2=0;
    int flag;
    ll tim[101]={0};
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        flag=0;
        cin>>x;
        sum+=x;
        sum2=sum-m;
        if(sum2>0)
        {
            for(int i=100;i>=1;i--)
            {
                if(tim[i]>0){
                flag+=sum2/i<=tim[i] ? sum2/i:tim[i];
                sum2=sum2-(flag*i);
                if(i>=sum2)
                {flag++;break;}
                }
            }
        }
        tim[x]++;
        a[i]=flag;
    }
    for(int i=0;i<n;i++)
    cout<<a[i]<<" ";
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define lli long long int

int main(){

	ios_base :: sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);

	lli n,M;

	cin>>n>>M;

	lli t[n];

	for(int i=0; i<n; i++){

		cin>>t[i];
	}

	lli sum = 0;

	map <lli,lli> q;

	for(int i=0; i<n; i++){

		lli c = 0;

		sum += t[i];

		lli sum_=sum;

		if(sum_ > M){

			auto it = q.rend();

			while(sum_ > M){

				lli x = it->first;

				lli y = it->second;

				lli z = sum_ - M;

				lli a;

				if(z%x == 0){

					a = z/x;
				}

				else if(z%x > 0){

					a = (z/x);

					a++;
				}

				else{

					a = 1;
				}

				a = min(y,a);

				sum_ -= (x*a);

				c += a;

				it--;
			}
		}

		cout<<c<<" ";

		q[t[i]]++;
	}
}


#include<bits/stdc++.h>

using namespace std;

int main(){

	ios_base :: sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);

	long long int n,M;

	cin>>n>>M;

	long long int t[n];

	for(int i=0; i<n; i++){

		cin>>t[i];
	}

	long long int sum = 0;

	multiset <long long int> q;

	for(int i=0; i<n; i++){

		long long int c = 0;

		sum += t[i];

		long long int sum_=sum;

		if(sum_ > M){

			auto it = q.end();

			while(sum_ > M){

				it--;

				int x = *it;

				sum_ -= x;

				c++;

				if(it == q.begin()){

					break;
				}
			}
		}

		cout<<c<<" ";

		q.insert(t[i]);
	}
}


#include<bits/stdc++.h>

using namespace std;

int main(){

	ios_base :: sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);

	long long int n,M;

	cin>>n>>M;

	long long int t[n];

	for(int i=0; i<n; i++){

		cin>>t[i];
	}

	long long int sum = 0;

	priority_queue <long long int> q,Q;

	for(int i=0; i<n; i++){

		q = Q;

		sum += t[i];

		long long int c = 0;

		long long int sum_=sum;

		while(sum_ > M){

			long long int x = q.top();

			q.pop();

			sum_ -= x;

			c++;
		}

		cout<<c<<" ";

		Q.push(t[i]);
	}
}


#include<bits/stdc++.h>

using namespace std;

#define lli long long int

int main(){

	ios_base :: sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);

	lli n,M;

	cin>>n>>M;

	lli t[n];

	for(int i=0; i<n; i++){

		cin>>t[i];
	}

	lli sum = 0;

	map <lli,lli> q;

	for(int i=0; i<n; i++){

		lli c = 0;

		sum += t[i];

		lli sum_=sum;

		if(sum_ > M){

			auto it = q.end();

			while(sum_ > M){

				it--;

				lli x = it->first;

				lli y = it->second;

				lli z = sum_ - M;

				lli a;

				if(z%x == 0){

					a = z/x;
				}

				else if(z>x){

					a = (ceil)(z/x);
				}

				else{

					a = 1;
				}

				a = min(y,a);

				sum_ -= (x*a);

				c += a;

				if(it == q.begin()){

					break;
				}
			}
		}

		cout<<c<<" ";

		q[t[i]]++;
	}
}


#include<bits/stdc++.h>

using namespace std;

#define lli long long int

int main(){

	ios_base :: sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);

	lli n,M;

	cin>>n>>M;

	lli t[n];

	for(int i=0; i<n; i++){

		cin>>t[i];
	}

	lli sum = 0;

	map <lli,lli> q;

	for(int i=0; i<n; i++){

		lli c = 0;

		sum += t[i];

		lli sum_=sum;

		if(sum_ > M){

			auto it = q.end();

			while(sum_ > M){

				it--;

				lli x = it->first;

				lli y = it->second;

				lli z = sum_ - M;

				lli a;

				if(z%x == 0){

					a = z/x;
				}

				else if(z%x > 0){

					a = (z/x);

					a++;
				}

				else{

					a = 1;
				}

				a = min(y,a);

				sum_ -= (x*a);

				c += a;

				if(it == q.begin()){

					break;
				}
			}
		}

		cout<<c<<" ";

		q[t[i]]++;
	}
}


#include<bits/stdc++.h>

using namespace std;

int main(){

	ios_base :: sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);

	int n,M;

	cin>>n>>M;

	int t[n];

	for(int i=0; i<n; i++){

		cin>>t[i];
	}

	long long int sum = 0;

	priority_queue <int> q,Q;

	for(int i=0; i<n; i++){

		q = Q;

		sum += t[i];

		int c = 0;

		long long int sum_=sum;

		while(sum_ > M){

			int x = q.top();

			q.pop();

			sum_ -= x;

			c++;
		}

		cout<<c<<" ";

		Q.push(t[i]);
	}
}


#include<bits/stdc++.h>

using namespace std;

int main(){

	ios_base :: sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);

	long long int n,M;

	cin>>n>>M;

	long long int t[n];

	for(int i=0; i<n; i++){

		cin>>t[i];
	}

	long long int sum = 0;

	multiset <long long int> q;

	for(int i=0; i<n; i++){

		sum += t[i];

		long long int c = 0;

		long long int sum_=sum;

		if(sum_ > M){

			auto it = q.end();

			while(sum_ > M){

				--it;

				int x = *it;

				sum_ -= x;

				c++;

				if(it == q.begin()){

					break;
				}
			}
		}

		cout<<c<<" ";

		q.insert(t[i]);
	}
}


#include<bits/stdc++.h>

using namespace std;

int main(){

	ios_base :: sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);

	int n,M;

	cin>>n>>M;

	int t[n];

	for(int i=0; i<n; i++){

		cin>>t[i];
	}

	long long int sum = 0;

	set <int> q,Q;

	for(int i=0; i<n; i++){

		q = Q;

		sum += t[i];

		int c = 0;

		long long int sum_=sum;

		while(sum_ > M){

			if(q.empty()){

				break;
			}

			auto p = q.end();

			--p;

			int x = *p;

			q.erase(p);

			sum_ -= x;

			c++;
		}

		cout<<c<<" ";

		Q.insert(t[i]);
	}
}


#include<bits/stdc++.h>

using namespace std;

int main(){

	ios_base :: sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);

	long long int n,M;

	cin>>n>>M;

	long long int t[n];

	for(int i=0; i<n; i++){

		cin>>t[i];
	}

	long long int sum = 0;

	priority_queue <long long int> q,Q;

	for(int i=0; i<n; i++){

		sum += t[i];

		long long int c = 0;

		long long int sum_=sum;

		if(sum_ > M){

			q = Q;

			while(sum_ > M){

				long long int x = q.top();

				q.pop();

				sum_ -= x;

				c++;

				if(q.empty()){

					break;
				}
			}
		}

		cout<<c<<" ";

		Q.push(t[i]);
	}
}


#include<bits/stdc++.h>

using namespace std;

#define lli long long int

int main(){

	ios_base :: sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);

	lli n,M;

	cin>>n>>M;

	lli t[n];

	for(int i=0; i<n; i++){

		cin>>t[i];
	}

	lli sum = 0;

	map <lli,lli> q;

	for(int i=0; i<n; i++){

		lli c = 0;

		sum += t[i];

		lli sum_=sum;

		if(sum_ > M){

			auto it = q.rend();

			while(sum_ > M){

				lli x = it->first;

				lli y = it->second;

				lli z = sum_ - M;

				lli a;

				if(z%x == 0){

					a = z/x;
				}

				else if(z%x > 0){

					a = (z/x);

					a++;
				}

				else{

					a = 1;
				}

				a = min(y,a);

				sum_ -= (x*a);

				c += a;

				it++;
			}
		}

		cout<<c<<" ";

		q[t[i]]++;
	}
}


/*----------AV1502-----------*/
#include "bits/stdc++.h"

using namespace std;

#define TEST(T) int T; sci(T) ; while(T--)
#define ll long long
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define all(V) V.begin(),V.end()
#define clr(V,val) memset(V,val,sizeof(V))
#define rep(X,A,N,C) for(X=A;X<=N;X+=C)
#define rept(X,A,N,C) for(X=A;X>=N;X-=C)
#define sci(X) scanf("%d",&X)
#define scl(X) scanf("%lld",&X)
#define scs(X) scanf("%s",&X)
#define pfi(X) printf("%d",X)
#define pfl(X) printf("%lld",X)
#define pfs(X) printf("%s",X)
#define sp printf(" ")
#define nxt printf("\n")
#define endl "\n";

const int MX=1e6 + 5;

const int INF=1e9;

const int M=1000000007;

vector <int> adj[100005];
vector <int> vis(100005,0);

void solve()
{

    return ;
}

int main()
{
	ios_base::sync_with_stdio(false);
	int t=1;
    //cin>>t;
    while(t--)
    {
        int n,m;
        cin>>n>>m;
        priority_queue <int> mx;
        priority_queue <int, vector <int>, greater <int> > mn;
        int sum=0;
        for(int i=0;i<n;i++)
        {
            int v;
            cin>>v;
            while(!mn.empty()&&sum+mn.top()<=m)
            {
                int x=mn.top();
                mn.pop();
                mx.push(x);
                sum+=x;
            }
            while(sum+v>m)
            {
                int x=mx.top();
                mx.pop();
                mn.push(x);
                sum-=x;
            }
            cout<<mn.size()<<' ';
            if(!mx.empty()&&mx.top()<v)
            {
                mn.push(v);
            }
            else
            {
                sum+=v;
                mx.push(v);
            }
        }
        //solve();
    }
	return 0;
}


/*----------AV1502-----------*/
#include "bits/stdc++.h"

using namespace std;

#define TEST(T) int T; sci(T) ; while(T--)
#define ll long long
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define all(V) V.begin(),V.end()
#define clr(V,val) memset(V,val,sizeof(V))
#define rep(X,A,N,C) for(X=A;X<=N;X+=C)
#define rept(X,A,N,C) for(X=A;X>=N;X-=C)
#define sci(X) scanf("%d",&X)
#define scl(X) scanf("%lld",&X)
#define scs(X) scanf("%s",&X)
#define pfi(X) printf("%d",X)
#define pfl(X) printf("%lld",X)
#define pfs(X) printf("%s",X)
#define sp printf(" ")
#define nxt printf("\n")
#define endl "\n";

const int MX=1e6 + 5;

const int INF=1e9;

const int M=1000000007;

vector <int> adj[100005];
vector <int> vis(100005,0);

void solve()
{

    return ;
}

int main()
{
	ios_base::sync_with_stdio(false);
	int t=1;
    //cin>>t;
    while(t--)
    {
        ll n,m;
        cin>>n>>m;
        priority_queue <ll> mx;
        priority_queue <ll, vector <ll>, greater<ll> >mn;
        ll sum=0;
        for(int i=0;i<n;i++)
        {
            int v;
            cin>>v;
            while(sum+v>m)
            {
                ll temp=mx.top();
                mx.pop();
                sum-=temp;
                ll s=0;
                while(!mn.empty()&&mn.top()<temp)
                {
                    s+=mn.top();
                    if(s<=temp)
                    {
                        sum+=mn.top();
                        mx.push(mn.top());
                        mn.pop();
                    }
                    else
                    {
                        break;
                    }
                }
                mn.push(temp);
            }
            sum+=v;
            cout<<mn.size()<<' ';
            mx.push(v);
        }

        //solve();
    }
	return 0;
}


/*----------AV1502-----------*/
#include "bits/stdc++.h"

using namespace std;

#define TEST(T) int T; sci(T) ; while(T--)
#define ll long long
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define all(V) V.begin(),V.end()
#define clr(V,val) memset(V,val,sizeof(V))
#define rep(X,A,N,C) for(X=A;X<=N;X+=C)
#define rept(X,A,N,C) for(X=A;X>=N;X-=C)
#define sci(X) scanf("%d",&X)
#define scl(X) scanf("%lld",&X)
#define scs(X) scanf("%s",&X)
#define pfi(X) printf("%d",X)
#define pfl(X) printf("%lld",X)
#define pfs(X) printf("%s",X)
#define sp printf(" ")
#define nxt printf("\n")
#define endl "\n";

const int MX=1e6 + 5;

const int INF=1e9;

const int M=1000000007;

vector <int> adj[100005];
vector <int> vis(100005,0);

void solve()
{

    return ;
}

int main()
{
	ios_base::sync_with_stdio(false);
	int t=1;
    //cin>>t;
    while(t--)
    {
        ll n,m;
        cin>>n>>m;
        priority_queue <ll> mx;
        priority_queue <ll, vector <ll>, greater<ll> >mn;
        ll sum=0;
        for(int i=0;i<n;i++)
        {
            int v;
            cin>>v;
            while(sum+v>m)
            {
                ll temp=mx.top();
                mx.pop();
                sum-=temp;
                ll s=0;
                while(!mn.empty())
                {
                    s+=mn.top();
                    if(s<temp)
                    {
                        sum+=mn.top();
                        mx.push(mn.top());
                        mn.pop();
                    }
                    else
                    {
                        break;
                    }
                }
                mn.push(temp);
            }
            sum+=v;
            cout<<mn.size()<<' ';
            mx.push(v);
        }

        //solve();
    }
	return 0;
}


/*----------AV1502-----------*/
#include "bits/stdc++.h"

using namespace std;

#define TEST(T) int T; sci(T) ; while(T--)
#define ll long long
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define all(V) V.begin(),V.end()
#define clr(V,val) memset(V,val,sizeof(V))
#define rep(X,A,N,C) for(X=A;X<=N;X+=C)
#define rept(X,A,N,C) for(X=A;X>=N;X-=C)
#define sci(X) scanf("%d",&X)
#define scl(X) scanf("%lld",&X)
#define scs(X) scanf("%s",&X)
#define pfi(X) printf("%d",X)
#define pfl(X) printf("%lld",X)
#define pfs(X) printf("%s",X)
#define sp printf(" ")
#define nxt printf("\n")
#define endl "\n";

const int MX=1e6 + 5;

const int INF=1e9;

const int M=1000000007;

vector <int> adj[100005];
vector <int> vis(100005,0);

void solve()
{

    return ;
}

int main()
{
	ios_base::sync_with_stdio(false);
	int t=1;
    //cin>>t;
    while(t--)
    {
        int n,m;
        cin>>n>>m;
        priority_queue <int> mx;
        priority_queue <int, vector <int>, greater <int> > mn;
        int sum=0;
        for(int i=0;i<n;i++)
        {
            int v;
            cin>>v;
            while(sum+v>m)
            {
                int tp=mx.top();
                sum-=tp;
                mx.pop();
                mn.push(tp);
            }
            sum+=v;
            while(!mn.empty()&&(sum+mn.top())<=m)
            {
                int tp=mn.top();
                sum+=tp;
                mn.pop();
                mx.push(tp);
            }
            cout<<mn.size()<<' ';
            mx.push(v);
        }
        //solve();
    }
	return 0;
}


/*----------AV1502-----------*/
#include "bits/stdc++.h"

using namespace std;

#define TEST(T) int T; sci(T) ; while(T--)
#define ll long long
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define all(V) V.begin(),V.end()
#define clr(V,val) memset(V,val,sizeof(V))
#define rep(X,A,N,C) for(X=A;X<=N;X+=C)
#define rept(X,A,N,C) for(X=A;X>=N;X-=C)
#define sci(X) scanf("%d",&X)
#define scl(X) scanf("%lld",&X)
#define scs(X) scanf("%s",&X)
#define pfi(X) printf("%d",X)
#define pfl(X) printf("%lld",X)
#define pfs(X) printf("%s",X)
#define sp printf(" ")
#define nxt printf("\n")
#define endl "\n";

const int MX=1e6 + 5;

const int INF=1e9;

const int M=1000000007;

vector <int> adj[100005];
vector <int> vis(100005,0);

void solve()
{

    return ;
}

int main()
{
	ios_base::sync_with_stdio(false);
	int t=1;
    //cin>>t;
    while(t--)
    {
        ll n,m;
        cin>>n>>m;
        priority_queue <ll> mx;
        priority_queue <ll, vector <ll>, greater<ll> >mn;
        ll sum=0;
        for(int i=0;i<n;i++)
        {
            int v;
            cin>>v;
            if(sum+v>m)
            {
                while(!mn.empty()&&!mx.empty())
                {
                    int p=mn.top();
                    int q=mx.top();
                    if(p<q)
                    {
                        mn.pop();
                        mx.pop();
                        mx.push(p);
                        mn.push(q);
                        sum+=p-q;
                    }
                    else
                    {
                        break;
                    }
                }
                while(sum+v>m)
                {
                    int p=mx.top();
                    mx.pop();
                    sum-=p;
                    mn.push(p);
                }
            }
            sum+=v;
            while(!mn.empty())
            {
                int p=mn.top();
                if(sum+p<=m)
                {
                    mn.pop();
                    mx.push(p);
                    sum+=p;
                }
                else
                {
                    break;
                }
            }
            cout<<mn.size()<<' ';
            mx.push(v);
        }

        //solve();
    }
	return 0;
}


/*----------AV1502-----------*/
#include "bits/stdc++.h"

using namespace std;

#define TEST(T) int T; sci(T) ; while(T--)
#define ll long long
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define all(V) V.begin(),V.end()
#define clr(V,val) memset(V,val,sizeof(V))
#define rep(X,A,N,C) for(X=A;X<=N;X+=C)
#define rept(X,A,N,C) for(X=A;X>=N;X-=C)
#define sci(X) scanf("%d",&X)
#define scl(X) scanf("%lld",&X)
#define scs(X) scanf("%s",&X)
#define pfi(X) printf("%d",X)
#define pfl(X) printf("%lld",X)
#define pfs(X) printf("%s",X)
#define sp printf(" ")
#define nxt printf("\n")
#define endl "\n";

const int MX=1e6 + 5;

const int INF=1e9;

const int M=1000000007;

vector <int> adj[100005];
vector <int> vis(100005,0);

void solve()
{

    return ;
}

int main()
{
	ios_base::sync_with_stdio(false);
	int t=1;
    //cin>>t;
    while(t--)
    {
        ll n,m;
        cin>>n>>m;
        priority_queue <ll> mx;
        priority_queue <ll, vector <ll>, greater<ll> >mn;
        ll sum=0;
        for(int i=0;i<n;i++)
        {
            int v;
            cin>>v;
            while(sum+v>m)
            {
                ll temp=mx.top();
                mx.pop();
                sum-=temp;
                while(!mn.empty()&&!mx.empty())
                {
                    int p=mn.top();
                    int q=mx.top();
                    if(p<q)
                    {
                        mn.pop();
                        mx.pop();
                        mx.push(p);
                        mn.push(q);
                        sum+=p-q;
                    }
                    else
                    {
                        break;
                    }
                }
                mn.push(temp);
            }
            sum+=v;
            while(!mn.empty())
            {
                int p=mn.top();
                if(sum+p<=m)
                {
                    mn.pop();
                    mx.push(p);
                    sum+=p;
                }
                else
                {
                    break;
                }
            }
            cout<<mn.size()<<' ';
            mx.push(v);
        }

        //solve();
    }
	return 0;
}


/*----------AV1502-----------*/
#include "bits/stdc++.h"

using namespace std;

#define TEST(T) int T; sci(T) ; while(T--)
#define ll long long
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define all(V) V.begin(),V.end()
#define clr(V,val) memset(V,val,sizeof(V))
#define rep(X,A,N,C) for(X=A;X<=N;X+=C)
#define rept(X,A,N,C) for(X=A;X>=N;X-=C)
#define sci(X) scanf("%d",&X)
#define scl(X) scanf("%lld",&X)
#define scs(X) scanf("%s",&X)
#define pfi(X) printf("%d",X)
#define pfl(X) printf("%lld",X)
#define pfs(X) printf("%s",X)
#define sp printf(" ")
#define nxt printf("\n")
#define endl "\n";

const int MX=1e6 + 5;

const int INF=1e9;

const int M=1000000007;

vector <int> adj[100005];
vector <int> vis(100005,0);

void solve()
{

    return ;
}

int main()
{
	ios_base::sync_with_stdio(false);
	int t=1;
    //cin>>t;
    while(t--)
    {
        int n,m;
        cin>>n>>m;
        priority_queue <int> mx;
        priority_queue <int, vector <int>, greater <int> > mn;
        int sum=0;
        for(int i=0;i<n;i++)
        {
            int v;
            cin>>v;
            while(!mn.empty()&&sum+v+mn.top()<=m)
            {
                sum+=mn.top();
                mx.push(mn.top());
                mn.pop();
            }
            while(!mx.empty()&&sum+v>m)
            {
                sum-=mx.top();
                mn.push(mx.top());
                mx.pop();
            }
            while(!mn.empty()&&sum+v+mn.top()<=m)
            {
                sum+=mn.top();
                mx.push(mn.top());
                mn.pop();
            }
            sum+=v;
            mx.push(v);
            cout<<mn.size()<<' ';
        }
        //solve();
    }
	return 0;
}


/*----------AV1502-----------*/
#include "bits/stdc++.h"

using namespace std;

#define TEST(T) int T; sci(T) ; while(T--)
#define ll long long
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define all(V) V.begin(),V.end()
#define clr(V,val) memset(V,val,sizeof(V))
#define rep(X,A,N,C) for(X=A;X<=N;X+=C)
#define rept(X,A,N,C) for(X=A;X>=N;X-=C)
#define sci(X) scanf("%d",&X)
#define scl(X) scanf("%lld",&X)
#define scs(X) scanf("%s",&X)
#define pfi(X) printf("%d",X)
#define pfl(X) printf("%lld",X)
#define pfs(X) printf("%s",X)
#define sp printf(" ")
#define nxt printf("\n")
#define endl "\n";

const int MX=1e6 + 5;

const int INF=1e9;

const int M=1000000007;

vector <int> adj[100005];
vector <int> vis(100005,0);

void solve()
{

    return ;
}

int main()
{
	ios_base::sync_with_stdio(false);
	int t=1;
    //cin>>t;
    while(t--)
    {
        ll n,m;
        cin>>n>>m;
        priority_queue <ll> mx;
        priority_queue <ll, vector <ll>, greater<ll> >mn;
        ll sum=0;
        for(int i=0;i<n;i++)
        {
            int v;
            cin>>v;
            while(sum+v>m)
            {
                ll temp=mx.top();
                mx.pop();
                sum-=temp;
                mn.push(temp);
            }
            sum+=v;
            while(!mn.empty()&&sum+mn.top()<=m)
            {
                sum+=mn.top();
                mx.push(mn.top());
                mn.pop();
            }
            cout<<mn.size()<<' ';
            mx.push(v);
        }

        //solve();
    }
	return 0;
}


/*----------AV1502-----------*/
#include "bits/stdc++.h"

using namespace std;

#define TEST(T) int T; sci(T) ; while(T--)
#define ll long long
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define all(V) V.begin(),V.end()
#define clr(V,val) memset(V,val,sizeof(V))
#define rep(X,A,N,C) for(X=A;X<=N;X+=C)
#define rept(X,A,N,C) for(X=A;X>=N;X-=C)
#define sci(X) scanf("%d",&X)
#define scl(X) scanf("%lld",&X)
#define scs(X) scanf("%s",&X)
#define pfi(X) printf("%d",X)
#define pfl(X) printf("%lld",X)
#define pfs(X) printf("%s",X)
#define sp printf(" ")
#define nxt printf("\n")
#define endl "\n";

const int MX=1e6 + 5;

const int INF=1e9;

const int M=1000000007;

vector <int> adj[100005];
vector <int> vis(100005,0);

void solve()
{

    return ;
}

int main()
{
	ios_base::sync_with_stdio(false);
	int t=1;
    //cin>>t;
    while(t--)
    {
        ll n,m;
        cin>>n>>m;
        priority_queue <ll> mx;
        priority_queue <ll, vector <ll>, greater<ll> >mn;
        ll sum=0;
        for(int i=0;i<n;i++)
        {
            int v;
            cin>>v;
            while(sum+v>m)
            {
                ll temp=mx.top();
                mx.pop();
                sum-=temp;
                if(!mn.empty())
                {
                    if(mn.top()<temp)
                    {
                        sum+=mn.top();
                        mx.push(mn.top());
                        mn.pop();
                    }
                }
                mn.push(temp);
            }
            sum+=v;
            cout<<mn.size()<<' ';
            mx.push(v);
        }

        //solve();
    }
	return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#define int long long
#define ld long double
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define ff first
#define ss second
#define endl '\n'
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define loop(i,l,r) for(int i=l;i<r;i++)
#define rloop(i,r,l) for(int i=r;i>=l;i--)
#define watch(x) cerr<<(#x)<<"= "<<(x)<<endl;
#define watcharr(a) cerr<<(#a)<<"("<<sz(a)<<")= ";rep(i,sz(a))cerr<<a[i]<<",";cerr<<'\n';
#define inf 2000000000000000000LL
#define mod 1000000007
#define mod1 998244353
#define FASTIO std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

signed main() {
    FASTIO;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("stderr.txt", "w", stderr);
    #endif

    // int tt=1;
    // cin>>tt;
    // while(tt--){
        int n,m,k,t,sum=0;
        cin>>n>>m;
        multiset<int> s;
        int count=0;
        rep(i,n){
            cin>>t;
            // sum+=t;
            if(sum+t<=m) cout<<0+count<<' ';
            else{
                int curr=0,c=0;
                auto it=s.rbegin();
                while(sum+t-curr>m){
                    curr+=*it;
                    it++;
                    c++;
                }
                cout<<c+count<<' ';
            }
            sum+=t, s.insert(t);
            if(sum>=m) count++, sum-=*s.rbegin(), s.erase(--s.end());

        }

    // }
    return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#define int long long
#define ld long double
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define ff first
#define ss second
#define endl '\n'
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define loop(i,l,r) for(int i=l;i<r;i++)
#define rloop(i,r,l) for(int i=r;i>=l;i--)
#define watch(x) cerr<<(#x)<<"= "<<(x)<<endl;
#define watcharr(a) cerr<<(#a)<<"("<<sz(a)<<")= ";rep(i,sz(a))cerr<<a[i]<<",";cerr<<'\n';
#define inf 2000000000000000000LL
#define mod 1000000007
#define mod1 998244353
#define FASTIO std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

signed main() {
    FASTIO;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("stderr.txt", "w", stderr);
    #endif

    // int tt=1;
    // cin>>tt;
    // while(tt--){
        int n,m,k,t,sum=0;
        cin>>n>>m;
        multiset<int> s;
        int count=0;
        rep(i,n){
            cin>>t;
            // sum+=t;
            if(sum+t<=m) cout<<0+count<<' ';
            else{
                int curr=0,c=0;
                auto it=s.rbegin();
                while(sum+t-curr>m){
                    curr+=*it;
                    it++;
                    c++;
                }
                cout<<c+count<<' ';
            }
            sum+=t;
            s.insert(t);
            // for(auto i:s) cerr<<i<<' '; cerr<<endl;
            if(sum>=m) count++, sum-=*s.rbegin(), s.erase(--s.end());
            // for(auto i:s) cerr<<i<<' '; cerr<<endl;
            // watch(i) watch(count)

        }

    // }
    return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#define int long long
#define ld long double
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define ff first
#define ss second
#define endl '\n'
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define loop(i,l,r) for(int i=l;i<r;i++)
#define rloop(i,r,l) for(int i=r;i>=l;i--)
#define watch(x) cerr<<(#x)<<"= "<<(x)<<endl;
#define watcharr(a) cerr<<(#a)<<"("<<sz(a)<<")= ";rep(i,sz(a))cerr<<a[i]<<",";cerr<<'\n';
#define inf 2000000000000000000LL
#define mod 1000000007
#define mod1 998244353
#define FASTIO std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

signed main() {
    FASTIO;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("stderr.txt", "w", stderr);
    #endif

    // int tt=1;
    // cin>>tt;
    // while(tt--){
        int n,m,k,t,sum=0;
        cin>>n>>m;
        multiset<int> s;
        int count=0;
        rep(i,n){
            cin>>t;
            // sum+=t;
            if(sum+t<=m) cout<<0+count<<' ';
            else{
                int curr=0,c=0;
                auto it=s.rbegin();
                while(sum+t-curr>m){
                    curr+=*it;
                    it++;
                    c++;
                }
                cout<<c+count<<' ';
            }
            sum+=t, s.insert(t);
            if(sum>=m) count++, sum-=*s.rbegin(), s.erase(--s.end());

        }

    // }
    return 0;
}


#include <bits/stdc++.h>
// #pragma GCC optimize ("O3")
#define int long long
#define ld long double
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define ff first
#define ss second
#define endl '\n'
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define loop(i,l,r) for(int i=l;i<r;i++)
#define rloop(i,r,l) for(int i=r;i>=l;i--)
#define watch(x) cerr<<(#x)<<"= "<<(x)<<endl;
#define watcharr(a) cerr<<(#a)<<"("<<sz(a)<<")= ";rep(i,sz(a))cerr<<a[i]<<",";cerr<<'\n';
#define inf 2000000000000000000LL
#define mod 1000000007
#define mod1 998244353
#define FASTIO std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

signed main() {
    FASTIO;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("stderr.txt", "w", stderr);
    #endif

    // int tt=1;
    // cin>>tt;
    // while(tt--){
        int n,m,k,t,sum=0;
        cin>>n>>m;
        multiset<int> s;
        int count=0;
        rep(i,n){
            cin>>t;
            // sum+=t;
            if(sum+t<=m) cout<<0+count<<' ';
            else{
                int curr=0,c=0;
                auto it=s.rbegin();
                while(sum+t-curr>m){
                    curr+=*it;
                    it++;
                    c++;
                }
                cout<<c+count<<' ';
            }
            sum+=t, s.insert(t);
            if(sum>=m) count++, sum-=*s.rbegin(), s.erase(--s.end());

        }

    // }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int T = 100;

int main() {
	int n, m;
	cin >> n >> m;

	int sum = 0;
	vector<int> t(n), count(T + 1, 0);
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}

	for (int i = 0; i < n; i++) {
		int d = sum + t[i] - m, k = 0;
		if (d > 0) {
		    for (int j = T; j > 0; j--) {
				int x = j * count[j];
				if (d <= x) {
					k += (d + j - 1) / j;
					break;
				}
				k += count[j];
				d -= x;
			}
		}
		sum += t[i];
		count[t[i]]++;
		cout << k << " ";
	}
}


#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#define int long long
#define ld long double
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define ff first
#define ss second
#define endl '\n'
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define loop(i,l,r) for(int i=l;i<r;i++)
#define rloop(i,r,l) for(int i=r;i>=l;i--)
#define watch(x) cerr<<(#x)<<"= "<<(x)<<endl;
#define watcharr(a) cerr<<(#a)<<"("<<sz(a)<<")= ";rep(i,sz(a))cerr<<a[i]<<",";cerr<<'\n';
#define inf 2000000000000000000LL
#define mod 1000000007
#define mod1 998244353
#define FASTIO std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

signed main() {
    FASTIO;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("stderr.txt", "w", stderr);
    #endif

    // int tt=1;
    // cin>>tt;
    // while(tt--){
        int n,m,k,t,sum=0;
        cin>>n>>m;
        multiset<int> s;
        int count=0;
        rep(i,n){
            cin>>t;
            // sum+=t;
            if(sum+t<=m) cout<<0+count<<' ';
            else{
                int curr=0,c=0;
                auto it=s.rbegin();
                while(sum+t-curr>m){
                    curr+=*it;
                    it++;
                    c++;
                }
                cout<<c+count<<' ';
            }
            sum+=t, s.insert(t);
            if(sum>=m) count++, sum-=*s.rbegin(), s.erase(--s.end());

        }

    // }
    return 0;
}


    #include <bits/stdc++.h>
    // #pragma GCC optimize ("O3")
    #define int long long
    #define ld long double
    #define pb push_back
    #define vi vector<int>
    #define pii pair<int,int>
    #define ff first
    #define ss second
    #define endl '\n'
    #define all(v) v.begin(),v.end()
    #define sz(v) (int)v.size()
    #define rep(i,n) for(int i=0;i<n;i++)
    #define rrep(i,n) for(int i=n;i>=0;i--)
    #define loop(i,l,r) for(int i=l;i<r;i++)
    #define rloop(i,r,l) for(int i=r;i>=l;i--)
    #define watch(x) cerr<<(#x)<<"= "<<(x)<<endl;
    #define watcharr(a) cerr<<(#a)<<"("<<sz(a)<<")= ";rep(i,sz(a))cerr<<a[i]<<",";cerr<<'\n';
    #define inf 2000000000000000000LL
    #define mod 1000000007
    #define mod1 998244353
    #define FASTIO std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    using namespace std;

    signed main() {
        FASTIO;
        #ifndef ONLINE_JUDGE
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
            freopen("stderr.txt", "w", stderr);
        #endif

        // int tt=1;
        // cin>>tt;
        // while(tt--){
            int n,m,k,t,sum=0;
            cin>>n>>m;
            multiset<int> s;
            map<int,int> mp;
            int count=0;
            rep(i,n){
                cin>>t;
                sum+=t;
                if(sum<=m) cout<<0+count<<' ';
                else{
                    int curr=0,c=0;
                    auto it=s.rbegin();
                    while(sum-curr>m and it!=s.rend()){
                        curr+=*it;
                        it++;
                        c++;
                    }
                    cout<<c+count<<' ';
                }
                s.insert(t);
                // for(auto i:s) cerr<<i<<' '; cerr<<endl;
                if(sum>=m) count++, sum-=*s.rbegin(), s.erase(--s.end());
                // for(auto i:s) cerr<<i<<' '; cerr<<endl;
                watch(i) watch(count)

            }

        // }
        return 0;
    }


#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#define int long long
#define ld long double
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define ff first
#define ss second
#define endl '\n'
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define loop(i,l,r) for(int i=l;i<r;i++)
#define rloop(i,r,l) for(int i=r;i>=l;i--)
#define watch(x) cerr<<(#x)<<"= "<<(x)<<endl;
#define watcharr(a) cerr<<(#a)<<"("<<sz(a)<<")= ";rep(i,sz(a))cerr<<a[i]<<",";cerr<<'\n';
#define inf 2000000000000000000LL
#define mod 1000000007
#define mod1 998244353
#define FASTIO std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

signed main() {
    FASTIO;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("stderr.txt", "w", stderr);
    #endif

    // int tt=1;
    // cin>>tt;
    // while(tt--){
        int n,m,k,t,sum=0;
        cin>>n>>m;
        multiset<int> s;
        map<int,int> mp;
        int count=0;
        rep(i,n){
            cin>>t;
            sum+=t;
            if(sum<=m) cout<<0+count<<' ';
            else{
                int curr=0,c=0;
                auto it=s.rbegin();
                while(sum-curr>m){
                    curr+=*it;
                    it++;
                    c++;
                }
                cout<<c+count<<' ';
            }
            s.insert(t);
            // for(auto i:s) cerr<<i<<' '; cerr<<endl;
            if(sum>=m) count++, sum-=*s.rbegin(), s.erase(--s.end());
            // for(auto i:s) cerr<<i<<' '; cerr<<endl;
            watch(i) watch(count)

        }

    // }
    return 0;
}


#include <bits/stdc++.h>
#pragma optimize ("O3")

using namespace std;

const int T = 100;

int main() {
	int n, m;
	cin >> n >> m;

	int sum = 0;
	vector<int> t(n), count(T + 1, 0);
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}

	for (int i = 0; i < n; i++) {
		int d = sum + t[i] - m, k = 0;
		if (d > 0) {
		    for (int j = T; j > 0; j--) {
				int x = j * count[j];
				if (d <= x) {
					k += (d + j - 1) / j;
					break;
				}
				k += count[j];
				d -= x;
			}
		}
		sum += t[i];
		count[t[i]]++;
		cout << k << " ";
	}
}


    #include<bits/stdc++.h>
    #pragma optimize ("O3")
    using namespace std;

    #define f first
    #define s second
    #define endl "\n"
    #define pb push_back
    #define  oo 0x3f3f3f3f
    #define limit 1000000007
    #define two pair<char,int>
    #define int long long int
    #define mod(x,m) ((x%m+m)%m)
    #define all(v) v.begin(),v.end()
    #define max3(x,y,z) max(x,max(y,z))
    #define min3(x,y,z) min(x,min(y,z))
    #define fori(x,n) for(int i = x; i < n; i++)
    #define forj(y,m) for(int j = y; j < m; j++)
    #define fork(z,p) for(int k = z; k < p; k++)
    #define fastio std::ios::sync_with_stdio(false)
    #define watch(x) cout << (#x) << " is " << (x) << "\n"
    #define input_from_file  freopen("input.txt", "r", stdin);

    signed main(){
      //input_from_file;
      fastio;
      int n,m; cin>>n>>m;
      multiset<int,greater<int>> s;
      int sum = 0;
      fori(0,n){
        int x; cin>>x;
        int c = 0;
        int tmp = sum;
        auto itr = s.begin();
        while((tmp+x) > m && itr != s.end()){
          c++;
          tmp -= *itr;
          itr++;
         }
         cout<<i-s.size()+c<<" ";
         sum += x;
         s.insert(x);
         if(sum >= m){
            sum -= *s.begin();
            s.erase(s.begin());
          }
       }
    }


#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#define int long long
#define ld long double
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define ff first
#define ss second
#define endl '\n'
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define loop(i,l,r) for(int i=l;i<r;i++)
#define rloop(i,r,l) for(int i=r;i>=l;i--)
#define watch(x) cerr<<(#x)<<"= "<<(x)<<endl;
#define watcharr(a) cerr<<(#a)<<"("<<sz(a)<<")= ";rep(i,sz(a))cerr<<a[i]<<",";cerr<<'\n';
#define inf 2000000000000000000LL
#define mod 1000000007
#define mod1 998244353
#define FASTIO std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

signed main() {
    FASTIO;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("stderr.txt", "w", stderr);
    #endif

    // int tt=1;
    // cin>>tt;
    // while(tt--){
        int n,m,k,t,sum=0;
        cin>>n>>m;
        multiset<int> s;
        map<int,int> mp;
        int count=0;
        rep(i,n){
            cin>>t;
            sum+=t;
            if(sum<=m) cout<<0+count<<' ';
            else{
                int curr=0,c=0;
                auto it=s.rbegin();
                while(sum-curr>m){
                    curr+=*it;
                    it++;
                    c++;
                }
                cout<<c+count<<' ';
            }
            s.insert(t);
            // for(auto i:s) cerr<<i<<' '; cerr<<endl;
            if(sum>=m) count++, sum-=*s.rbegin(), s.erase(--s.end());
            // for(auto i:s) cerr<<i<<' '; cerr<<endl;
            watch(i) watch(count)

        }

    // }
    return 0;
}


        #include <bits/stdc++.h>
        // #pragma GCC optimize ("O3")
        #define int long long
        #define ld long double
        #define pb push_back
        #define vi vector<int>
        #define pii pair<int,int>
        #define ff first
        #define ss second
        #define endl '\n'
        #define all(v) v.begin(),v.end()
        #define sz(v) (int)v.size()
        #define rep(i,n) for(int i=0;i<n;i++)
        #define rrep(i,n) for(int i=n;i>=0;i--)
        #define loop(i,l,r) for(int i=l;i<r;i++)
        #define rloop(i,r,l) for(int i=r;i>=l;i--)
        #define watch(x) cerr<<(#x)<<"= "<<(x)<<endl;
        #define watcharr(a) cerr<<(#a)<<"("<<sz(a)<<")= ";rep(i,sz(a))cerr<<a[i]<<",";cerr<<'\n';
        #define inf 2000000000000000000LL
        #define mod 1000000007
        #define mod1 998244353
        #define FASTIO std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
        using namespace std;

        signed main() {
            FASTIO;
            #ifndef ONLINE_JUDGE
                freopen("input.txt", "r", stdin);
                freopen("output.txt", "w", stdout);
                freopen("stderr.txt", "w", stderr);
            #endif

            // int tt=1;
            // cin>>tt;
            // while(tt--){
                int n,m,k,t,sum=0;
                cin>>n>>m;
                multiset<int> s;
                map<int,int> mp;
                int count=0;
                rep(i,n){
                    cin>>t;
                    sum+=t;
                    if(sum<=m) cout<<0+count<<' ';
                    else{
                        int curr=0,c=0;
                        auto it=s.rbegin();
                        while(sum-curr>m and it!=s.rend()){
                            curr+=*it;
                            it++;
                            c++;
                        }
                        cout<<c+count<<' ';
                    }
                    s.insert(t);
                    // for(auto i:s) cerr<<i<<' '; cerr<<endl;
                    if(sum>=m) count++, sum-=*s.rbegin(), s.erase(--s.end());
                    // for(auto i:s) cerr<<i<<' '; cerr<<endl;
                    // watch(i) watch(count)

                }

            // }
            return 0;
        }


#include <bits/stdc++.h>
// #pragma GCC optimize ("O3")
#define int long long
#define ld long double
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define ff first
#define ss second
#define endl '\n'
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define loop(i,l,r) for(int i=l;i<r;i++)
#define rloop(i,r,l) for(int i=r;i>=l;i--)
#define watch(x) cerr<<(#x)<<"= "<<(x)<<endl;
#define watcharr(a) cerr<<(#a)<<"("<<sz(a)<<")= ";rep(i,sz(a))cerr<<a[i]<<",";cerr<<'\n';
#define inf 2000000000000000000LL
#define mod 1000000007
#define mod1 998244353
#define FASTIO std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

signed main() {
    FASTIO;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("stderr.txt", "w", stderr);
    #endif

    // int tt=1;
    // cin>>tt;
    // while(tt--){
        int n,m,k,t,sum=0;
        cin>>n>>m;
        multiset<int> s;
        map<int,int> mp;
        int count=0;
        rep(i,n){
            cin>>t;
            sum+=t;
            if(sum<=m) cout<<0+count<<' ';
            else{
                int curr=0,c=0;
                auto it=s.rbegin();
                while(sum-curr>m){
                    curr+=*it;
                    it++;
                    c++;
                }
                cout<<c+count<<' ';
            }
            s.insert(t);
            // for(auto i:s) cerr<<i<<' '; cerr<<endl;
            if(sum>=m) count++, sum-=*s.rbegin(), s.erase(--s.end());
            // for(auto i:s) cerr<<i<<' '; cerr<<endl;
            watch(i) watch(count)

        }

    // }
    return 0;
}


/**
Monday left me broken
Tuesday I was through with hoping
Wednesday my empty arms were open
Thursday waiting for love, waiting for love
Thank the stars it's Friday
I'm burning like a fire gone wild on Saturday
Guess I won't be coming to church on Sunday
I'll be waiting for love, waiting for love
To come around
**/

#include <bits/stdc++.h>

using namespace std;

typedef pair <long long ,long long>	PII;
typedef priority_queue<PII,vector<PII>,greater<PII>> pairMinHeap;
typedef priority_queue<PII> pairMaxHeap;
typedef priority_queue<long long ,vector<long long>,greater<long long>> minHeap;
typedef priority_queue<long long> maxHeap;

#define what_is(x) cerr <<#x<<" is "<<x<<endl;
#define wis(x,y) cerr <<#x<<" is "<<x<<" and "<<#y<<" is "<<y<<endl;

long long INF=1e17;
const int N=5e5+33;
const long long MD=24;

inline long long mul(long long a, long long b){
    return (a*b)%MD;
}

inline long long po(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1)ans = mul(ans,a);
        a = mul(a,a);
        b/=2;
    }
    return ans;
}

long long n,m,t,k;
long long arr[N];
long long x;
string s;

int j=0;
int main(){
    ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>arr[i];

	multiset<int> st;
	int ans=0;
	multiset<int>::iterator it=st.end();
	long long sum=0,fi=0;

	for(int i=0;i<n;i++){
		sum+=arr[i];
		//cerr<<sum<<":"<<fi<<endl;
		while(m-sum+fi<0){
		j--;	it--;
			ans++;
			//cerr<<*it<<" ";
			fi+=*it;
		}
bool is=0;
		while(st.size()>0 && it!=(--st.end()) && it!=st.end() && m-sum+fi-*(++it)>=0){
		j++;	is=1;
			ans--;
			fi-=*it;
			if(!(st.size()>0 && it!=(--st.end()) && it!=st.end())){is=0;break;}
		}

		if(is)it--,j--;

		cout<<ans<<";"<<j<<" ";
		st.insert(arr[i]);
		if(it!=st.end() && arr[i]>*it){
			ans++;
			fi+=arr[i];
		}

	}

    return 0;
}


/**
Monday left me broken
Tuesday I was through with hoping
Wednesday my empty arms were open
Thursday waiting for love, waiting for love
Thank the stars it's Friday
I'm burning like a fire gone wild on Saturday
Guess I won't be coming to church on Sunday
I'll be waiting for love, waiting for love
To come around
**/

#include <bits/stdc++.h>

using namespace std;

typedef pair <long long ,long long>	PII;
typedef priority_queue<PII,vector<PII>,greater<PII>> pairMinHeap;
typedef priority_queue<PII> pairMaxHeap;
typedef priority_queue<long long ,vector<long long>,greater<long long>> minHeap;
typedef priority_queue<long long> maxHeap;

#define what_is(x) cerr <<#x<<" is "<<x<<endl;
#define wis(x,y) cerr <<#x<<" is "<<x<<" and "<<#y<<" is "<<y<<endl;

long long INF=1e17;
const int N=5e5+33;
const long long MD=24;

inline long long mul(long long a, long long b){
    return (a*b)%MD;
}

inline long long po(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1)ans = mul(ans,a);
        a = mul(a,a);
        b/=2;
    }
    return ans;
}

long long n,m,t,k;
long long arr[N];
long long x;
string s;

int main(){
    ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>arr[i];

	multiset<int> st;
	int ans=0;
	multiset<int>::iterator it=st.end();
	long long sum=0,fi=0;

	for(int i=0;i<n;i++){
		sum+=arr[i];
		//cerr<<sum<<":"<<fi<<endl;
		while(m-sum+fi<0){
			it--;
			ans++;
			//cerr<<*it<<" ";
			fi+=*it;
		}
bool is=0;
		while(st.size()>0 && it!=(--st.end()) && it!=st.end() && m-sum+fi-*(++it)>0){
			is=1;
			ans--;
			fi-=*it;
			if(!(st.size()>0 && it!=(--st.end()) && it!=st.end())){is=0;break;}
		}

		if(is)it--;

		cout<<ans<<" ";
		st.insert(arr[i]);
		if(it!=st.end() && arr[i]>=*it){
			ans++;
			fi+=arr[i];
		}

	}

    return 0;
}


/**
Monday left me broken
Tuesday I was through with hoping
Wednesday my empty arms were open
Thursday waiting for love, waiting for love
Thank the stars it's Friday
I'm burning like a fire gone wild on Saturday
Guess I won't be coming to church on Sunday
I'll be waiting for love, waiting for love
To come around
**/

#include <bits/stdc++.h>

using namespace std;

typedef pair <long long ,long long>	PII;
typedef priority_queue<PII,vector<PII>,greater<PII>> pairMinHeap;
typedef priority_queue<PII> pairMaxHeap;
typedef priority_queue<long long ,vector<long long>,greater<long long>> minHeap;
typedef priority_queue<long long> maxHeap;

#define what_is(x) cerr <<#x<<" is "<<x<<endl;
#define wis(x,y) cerr <<#x<<" is "<<x<<" and "<<#y<<" is "<<y<<endl;

long long INF=1e17;
const int N=5e5+33;
const long long MD=24;

inline long long mul(long long a, long long b){
    return (a*b)%MD;
}

inline long long po(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1)ans = mul(ans,a);
        a = mul(a,a);
        b/=2;
    }
    return ans;
}

long long n,m,t,k;
long long arr[N];
long long x;
string s;

int main(){
    ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>arr[i];

	multiset<int> st;
	int ans=0;
	multiset<int>::iterator it=st.end();
	long long sum=0,fi=0;

	for(int i=0;i<n;i++){
		sum+=arr[i];
		//cerr<<sum<<":"<<fi<<endl;
		while(m-sum+fi<0){
			it--;
			ans++;
			//cerr<<*it<<" ";
			fi+=*it;
		}
bool is=0;
		while(st.size()>0 && it!=(--st.end()) && it!=st.end() && m-sum+fi-*(++it)>=0){
			is=1;
			ans--;
			fi-=*it;
			if(!(st.size()>0 && it!=(--st.end()) && it!=st.end())){is=0;break;}
		}

		if(is)it--;

		cout<<ans<<" ";
		st.insert(arr[i]);
		if(it!=st.end() && arr[i]>=*it){
			ans++;
			fi+=arr[i];
		}

	}

    return 0;
}