        #include<bits/stdc++.h>
        #define int ll
        #define M 1000000007
        #define hell 998244353
        #define inf 1e18
        #define pb push_back
        #define pi 3.1415926536
        #define mp make_pair
        #define ub upper_bound
        #define lb lower_bound
        #define all(a) a.begin(),a.end()
        #define ll long long
        #define vec vector <int>
        #define pii pair<int,int>
        #define endl "\n"
        #define gcd __gcd
        using namespace std;
        int power(int x, unsigned int y, unsigned int m)
        {
            if (y == 0)
                return 1;
            int p = power(x, y/2, m) % m;
            p = (p * p) % m;

            return (y%2 == 0)? p : (x * p) % m;
        }
        int modInverse(int a, int m)
        {
            return power(a, m-2, m);
        }
        int nCrModPFermat(int n, int r, int p)
        {
               if (r==0)
                  return 1;

            int fac[n+1];
            fac[0] = 1;
            for (int i=1 ; i<=n; i++)
                fac[i] = fac[i-1]*i%p;

            return (fac[n]* modInverse(fac[r], p) % p *
                modInverse(fac[n-r], p) % p) % p;
        }
        signed main()
        {
            ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
            ll t=1;
            cin >> t;
             int ar[63];
                ar[0]=1;
                for (int i = 1; i < 63; ++i)
                {
                    ar[i]=ar[i-1]*2+1;
                }
            /*SAARE INPUTS LENA*/
            /*VARIABLES KI RANGE DEKHLENA*/
            /*EXPONENT RANGE OF OUTPUT KA DHYAN RAKHNA*/
            while(t-->0)
            {
                ll n=0;cin>>n;
                int ans=0;
                while(n!=0)
                {
                    int u=log2(n);
                    int v=pow(2,u);
                    n-=v;
                    ans+=ar[u];
                }
                cout<<ans<<endl;
            }
            return 0;
        }


    #include<bits/stdc++.h>
    #define int ll
    #define M 1000000007
    #define hell 998244353
    #define inf 1e18
    #define pb push_back
    #define pi 3.1415926536
    #define mp make_pair
    #define ub upper_bound
    #define lb lower_bound
    #define all(a) a.begin(),a.end()
    #define ll long long
    #define vec vector <int>
    #define pii pair<int,int>
    #define endl "\n"
    #define gcd __gcd
    using namespace std;
    int power(int x, unsigned int y, unsigned int m)
    {
        if (y == 0)
            return 1;
        int p = power(x, y/2, m) % m;
        p = (p * p) % m;

        return (y%2 == 0)? p : (x * p) % m;
    }
    int modInverse(int a, int m)
    {
        return power(a, m-2, m);
    }
    int nCrModPFermat(int n, int r, int p)
    {
           if (r==0)
              return 1;

        int fac[n+1];
        fac[0] = 1;
        for (int i=1 ; i<=n; i++)
            fac[i] = fac[i-1]*i%p;

        return (fac[n]* modInverse(fac[r], p) % p *
            modInverse(fac[n-r], p) % p) % p;
    }
    signed main()
    {
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        ll t=1;
        cin >> t;
        /*SAARE INPUTS LENA*/
        /*VARIABLES KI RANGE DEKHLENA*/
        /*EXPONENT RANGE OF OUTPUT KA DHYAN RAKHNA*/
        while(t-->0)
        {
            ll n=0;
            cin>>n;
            ll odd=ceil((double(n))/2.0);
            // cout<<odd<<" ";
            ll ans=0,even=0;
            ll u=log2(n);
            // cout<<u<<" ";
            ll v=1;
            for (int i = 0; i < u; ++i)
            {
                v*=2;
            }
            // cout<<u<<" "<<v<<" ";
            while(v!=1)
            {
                // cout<<(u+1)*(n/v-even);
                ans+=(u+1)*(n/v-even);
                even+=(n/v-even);
                v/=2;
                u--;
            }
            ll s=odd+ans;
            cout<<s<<endl;
        }
        return 0;
    }


    #include<bits/stdc++.h>
    #define int ll
    #define M 1000000007
    #define hell 998244353
    #define inf 1e18
    #define pb push_back
    #define pi 3.1415926536
    #define mp make_pair
    #define ub upper_bound
    #define lb lower_bound
    #define all(a) a.begin(),a.end()
    #define ll long long
    #define vec vector <int>
    #define pii pair<int,int>
    #define endl "\n"
    #define gcd __gcd
    using namespace std;
    int power(int x, unsigned int y, unsigned int m)
    {
        if (y == 0)
            return 1;
        int p = power(x, y/2, m) % m;
        p = (p * p) % m;

        return (y%2 == 0)? p : (x * p) % m;
    }
    int modInverse(int a, int m)
    {
        return power(a, m-2, m);
    }
    int nCrModPFermat(int n, int r, int p)
    {
           if (r==0)
              return 1;

        int fac[n+1];
        fac[0] = 1;
        for (int i=1 ; i<=n; i++)
            fac[i] = fac[i-1]*i%p;

        return (fac[n]* modInverse(fac[r], p) % p *
            modInverse(fac[n-r], p) % p) % p;
    }
    signed main()
    {
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        ll t=1;
        cin >> t;
        /*SAARE INPUTS LENA*/
        /*VARIABLES KI RANGE DEKHLENA*/
        /*EXPONENT RANGE OF OUTPUT KA DHYAN RAKHNA*/
        while(t-->0)
        {
            ll n=0;
            cin>>n;
            ll odd=ceil((double(n))/2.0);
            // cout<<odd<<" ";
            ll ans=0,even=0;
            ll u=log2(n);
            // cout<<u<<" ";
            ll v=pow(2,u);
            // for (int i = 0; i < u; ++i)
            // {
            //     v*=2;
            // }
            // cout<<u<<" "<<v<<" ";
            while(v!=1)
            {
                // cout<<(u+1)*(n/v-even);
                ans+=(u+1)*(n/v-even);
                even+=(n/v-even);
                v/=2;
                u--;
            }
            ll s=odd+ans;
            cout<<s<<endl;
        }
        return 0;
    }


        #include<bits/stdc++.h>
        #define int ll
        #define M 1000000007
        #define hell 998244353
        #define inf 1e18
        #define pb push_back
        #define pi 3.1415926536
        #define mp make_pair
        #define ub upper_bound
        #define lb lower_bound
        #define all(a) a.begin(),a.end()
        #define ll long long
        #define vec vector <int>
        #define pii pair<int,int>
        #define endl "\n"
        #define gcd __gcd
        using namespace std;
        int power(int x, unsigned int y, unsigned int m)
        {
            if (y == 0)
                return 1;
            int p = power(x, y/2, m) % m;
            p = (p * p) % m;

            return (y%2 == 0)? p : (x * p) % m;
        }
        int modInverse(int a, int m)
        {
            return power(a, m-2, m);
        }
        int nCrModPFermat(int n, int r, int p)
        {
               if (r==0)
                  return 1;

            int fac[n+1];
            fac[0] = 1;
            for (int i=1 ; i<=n; i++)
                fac[i] = fac[i-1]*i%p;

            return (fac[n]* modInverse(fac[r], p) % p *
                modInverse(fac[n-r], p) % p) % p;
        }
        signed main()
        {
            ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
            ll t=1;
            cin >> t;
            map <int,int> m;
            m[0]=0;
            m[1]=1;
            m[2]=3;
            ll x=pow(2,60);
            for (int i = 4; i <=x; i*=2)
            {
            	m[i]=m[i/2]*2+1;
            }
             int ar[63];
                ar[0]=1;
                for (int i = 1; i < 63; ++i)
                {
                    ar[i]=ar[i-1]*2+1;
                }
            /*SAARE INPUTS LENA*/
            /*VARIABLES KI RANGE DEKHLENA*/
            /*EXPONENT RANGE OF OUTPUT KA DHYAN RAKHNA*/
            while(t-->0)
            {
                ll n=0;cin>>n;
                int ans=0;
                while(n!=0)
                {
                	int z=1;
                	while(z<=n)
                		z*=2;
                	z/=2;
                    ans+=m[z];
                    n-=z;
                    // ans+=ar[u];
                }
                cout<<ans<<endl;
            }
            return 0;
        }


    #include<bits/stdc++.h>
    #define int ll
    #define M 1000000007
    #define hell 998244353
    #define inf 1e18
    #define pb push_back
    #define pi 3.1415926536
    #define mp make_pair
    #define ub upper_bound
    #define lb lower_bound
    #define all(a) a.begin(),a.end()
    #define ll long long
    #define vec vector <int>
    #define pii pair<int,int>
    #define endl "\n"
    #define gcd __gcd
    using namespace std;
    int power(int x, unsigned int y, unsigned int m)
    {
        if (y == 0)
            return 1;
        int p = power(x, y/2, m) % m;
        p = (p * p) % m;

        return (y%2 == 0)? p : (x * p) % m;
    }
    int modInverse(int a, int m)
    {
        return power(a, m-2, m);
    }
    int nCrModPFermat(int n, int r, int p)
    {
           if (r==0)
              return 1;

        int fac[n+1];
        fac[0] = 1;
        for (int i=1 ; i<=n; i++)
            fac[i] = fac[i-1]*i%p;

        return (fac[n]* modInverse(fac[r], p) % p *
            modInverse(fac[n-r], p) % p) % p;
    }
    signed main()
    {
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        ll t=1;
        cin >> t;
        /*SAARE INPUTS LENA*/
        /*VARIABLES KI RANGE DEKHLENA*/
        /*EXPONENT RANGE OF OUTPUT KA DHYAN RAKHNA*/
        while(t-->0)
        {
            ll n=0;cin>>n;
            int ar[63];
            ar[0]=1;
            for (int i = 1; i < 63; ++i)
            {
                ar[i]=ar[i-1]*2+1;
            }
            int ans=0;
            while(n!=0)
            {
                int u=log2(n);
                int v=pow(2,u);
                n-=v;
                ans+=ar[u];
            }
            cout<<ans<<endl;
        }
        return 0;
    }


        #include<bits/stdc++.h>
        #define int ll
        #define M 1000000007
        #define hell 998244353
        #define inf 1e18
        #define pb push_back
        #define pi 3.1415926536
        #define mp make_pair
        #define ub upper_bound
        #define lb lower_bound
        #define all(a) a.begin(),a.end()
        #define ll long long
        #define vec vector <int>
        #define pii pair<int,int>
        #define endl "\n"
        #define gcd __gcd
        using namespace std;
        int power(int x, unsigned int y, unsigned int m)
        {
            if (y == 0)
                return 1;
            int p = power(x, y/2, m) % m;
            p = (p * p) % m;

            return (y%2 == 0)? p : (x * p) % m;
        }
        int modInverse(int a, int m)
        {
            return power(a, m-2, m);
        }
        int nCrModPFermat(int n, int r, int p)
        {
               if (r==0)
                  return 1;

            int fac[n+1];
            fac[0] = 1;
            for (int i=1 ; i<=n; i++)
                fac[i] = fac[i-1]*i%p;

            return (fac[n]* modInverse(fac[r], p) % p *
                modInverse(fac[n-r], p) % p) % p;
        }
        signed main()
        {
            ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
            ll t=1;
            cin >> t;
            /*SAARE INPUTS LENA*/
            /*VARIABLES KI RANGE DEKHLENA*/
            /*EXPONENT RANGE OF OUTPUT KA DHYAN RAKHNA*/
            while(t-->0)
            {
                ll n=0;
                cin>>n;
                ll odd=ceil((double(n))/2.0);
                ll ans=0,even=0;
                ll u=log(n)/log(2);
                ll v=1;
                for (int i = 0; i < u; ++i)
                {
                    v*=2;
                }
                // cout<<n<<" "<<u<<" "<<v<<" ";
                while(v!=1)
                {
                    // cout<<(u+1)*(n/v-even);
                    ans+=(u+1)*(ceil(n/(v*2.0)));
                    // even+=(n/v-even);
                    v/=2;
                    u--;
                }
                cout<<odd+ans<<endl;
            }
            return 0;
        }


#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pll pair<ll ,ll>
#define rep(i, a, b) \
    for (int i = int(a); i <= int(b); i++)
#define case int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mpp make_pair
#define mpt make_tuple
#define pb push_back
#define mod 1000000007
#define intmin 0.0000001
#define all(x) x.begin(),x.end()
#define sc second
#define f first
ll pr[70];
ll power(ll a,ll b){
	ll res=1LL;
	while(b!=0){
		if(b%2){
			res=res*a;
		}
		a=a*a;
		b=b>>1;
	}
	return res;
}
ll solve(ll n){
	if(n==0){
		return 0;
	}
	ll u = log2(n);
	ll ans=0;
	ans+=pr[u];
	ll h = n-pow(2LL,u);
	ans+=solve(h);
	return ans;
}
int main(){
	pr[0]=1;
	pr[1]=3;
	for(int i=2;i<70;i+=1){
		pr[i]=pr[i-1]+pr[i-1]+1LL;
	}
	case{
		ll n;
		cin>>n;
		ll ans=0;
		ans = solve(n);
		cout<<ans<<endl;
	}
}


#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pll pair<ll ,ll>
#define rep(i, a, b) \
    for (int i = int(a); i <= int(b); i++)
#define case int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mpp make_pair
#define mpt make_tuple
#define pb push_back
#define mod 1000000007
#define intmin 0.0000001
#define all(x) x.begin(),x.end()
#define sc second
#define f first
ll pr[66];
ll power(ll a,ll b){
	ll res=1;
	while(b!=0){
		if(b%2){
			res=res*a;
		}
		a=a*a;
		b=b>>1;
	}
	return res;
}
ll solve(ll n){
	ll u = log2(n);
	//cout<<u<<endl;
	ll ans=0;
	ans+=pr[u];
	ll h = n-pow(2,u);
	if(h==0){
		return ans;
	}
	ans+=solve(h);
	return ans;
}
int main(){
	pr[0]=1;
	pr[1]=3;
	for(int i=2;i<=66;i+=1){
		pr[i]=pr[i-1]+pr[i-1]+1;
	}
	case{
		ll n;
		cin>>n;
		ll ans=0;
		ans = solve(n);
		cout<<ans<<endl;
	}
}


#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pll pair<ll ,ll>
#define rep(i, a, b) \
    for (int i = int(a); i <= int(b); i++)
#define case int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mpp make_pair
#define mpt make_tuple
#define pb push_back
#define mod 1000000007
#define intmin 0.0000001
#define all(x) x.begin(),x.end()
#define sc second
#define f first
ll pr[66];
ll power(ll a,ll b){
	ll res=1LL;
	while(b!=0){
		if(b%2){
			res=res*a;
		}
		a=a*a;
		b=b>>1;
	}
	return res;
}
ll solve(ll n){
	if(n==0){
		return 0;
	}
	ll u = log2(n);
	ll ans=0;
	ans+=pr[u];
	ll h = n-pow(2LL,u);
	ans+=solve(h);
	return ans;
}
int main(){
	pr[0]=1;
	pr[1]=3;
	for(int i=2;i<=66;i+=1){
		pr[i]=pr[i-1]+pr[i-1]+1LL;
	}
	case{
		ll n;
		cin>>n;
		ll ans=0;
		ans = solve(n);
		cout<<ans<<endl;
	}
}


#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pll pair<ll ,ll>
#define rep(i, a, b) \
    for (int i = int(a); i <= int(b); i++)
#define case int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mpp make_pair
#define mpt make_tuple
#define pb push_back
#define mod 1000000007
#define intmin 0.0000001
#define all(x) x.begin(),x.end()
#define sc second
#define f first
ll pr[70];
ll power(ll a,ll b){
	ll res=1LL;
	while(b!=0){
		if(b%2){
			res=res*a;
		}
		a=a*a;
		b=b>>1;
	}
	return res;
}
ll solve(ll n){
	if(n==0){
		return 0;
	}
	ll u = log2(n);
	ll ans=0;
	ans+=pr[u];
	ll h = n-(1LL<<(u));
	ans+=solve(h);
	return ans;
}
int main(){
	pr[0]=1;
	pr[1]=3;
	for(int i=2;i<70;i+=1){
		pr[i]=pr[i-1]+pr[i-1]+1LL;
	}
	case{
		ll n;
		cin>>n;
		ll ans = solve(n);
		cout<<ans<<endl;
	}
}


#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pll pair<ll ,ll>
#define rep(i, a, b) \
    for (int i = int(a); i <= int(b); i++)
#define case int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mpp make_pair
#define mpt make_tuple
#define pb push_back
#define mod 1000000007
#define intmin 0.0000001
#define all(x) x.begin(),x.end()
#define sc second
#define f first
ll pr[70];
ll power(ll a,ll b){
	ll res=1LL;
	while(b!=0){
		if(b%2){
			res=res*a;
		}
		a=a*a;
		b=b>>1;
	}
	return res;
}
ll solve(ll n){
	if(n==0){
		return 0;
	}
	ll k=n;
	ll u=0;
	while(k!=0){
		k=k>>1;
		u++;
	}
	u--;
	ll ans=0;
	ans+=pr[u];
	ll h = n-power(2LL,u);
	ans+=solve(h);
	return ans;
}
int main(){
	pr[0]=1;
	pr[1]=3;
	for(int i=2;i<70;i+=1){
		pr[i]=pr[i-1]+pr[i-1]+1LL;
	}
	case{
		ll n;
		cin>>n;
		ll ans = solve(n);
		cout<<ans<<endl;
	}
}


#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pll pair<ll ,ll>
#define rep(i, a, b) \
    for (int i = int(a); i <= int(b); i++)
#define case int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mpp make_pair
#define mpt make_tuple
#define pb push_back
#define mod 1000000007
#define intmin 0.0000001
#define all(x) x.begin(),x.end()
#define sc second
#define f first
ll pr[70];
ll power(ll a,ll b){
	ll res=1LL;
	while(b!=0){
		if(b%2){
			res=res*a;
		}
		a=a*a;
		b=b>>1;
	}
	return res;
}
ll solve(ll n){
	if(n==0){
		return 0;
	}
	ll u = log2(n);
	ll ans=0;
	ans+=pr[u];
	ll h = n-power(2LL,u);
	ans+=solve(h);
	return ans;
}
int main(){
	pr[0]=1;
	pr[1]=3;
	for(int i=2;i<70;i+=1){
		pr[i]=pr[i-1]+pr[i-1]+1LL;
	}
	case{
		ll n;
		cin>>n;
		ll ans = solve(n);
		cout<<ans<<endl;
	}
}


#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pll pair<ll ,ll>
#define rep(i, a, b) \
    for (int i = int(a); i <= int(b); i++)
#define case int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mpp make_pair
#define mpt make_tuple
#define pb push_back
#define mod 1000000007
#define intmin 0.0000001
#define all(x) x.begin(),x.end()
#define sc second
#define f first
ll pr[70];

ll solve(ll n){
	if(n==0){
		return 0;
	}
	ll u = 0;
	ll k=n;
	while(k!=0){
		u++;
		k=k>>1;
	}
	u--;
	ll ans=0;
	ans+=pr[u];
	ll h = n-(1LL<<(u));
	ans+=solve(h);
	return ans;
}
int main(){
	pr[0]=1;
	pr[1]=3;
	for(int i=2;i<70;i+=1){
		pr[i]=pr[i-1]+pr[i-1]+1LL;
	}
	case{
		ll n;
		cin>>n;
		ll ans = solve(n);
		cout<<ans<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
    int n;
    long long sum{},b{},i{},j{-1},t;
    cin>>n>>t;
    vector<long long> a(n);
    for(i=0;i<n;i++)
    cin>>a[i];
    for(i=0;i<n;i++)
    {
        sum+=a[i];
        if(sum>t)
        {
            while(sum>t)
            {
                j++;
                sum-=a[j];
            }
        }
        b=max(b,i-j);
    }
    cout<<b<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int RightsequenceFinding(int array[],int index,int length,int time){
	int sum = 0;int counter = 0;
	for(int x = index;x<length;x++){
		if(sum+ array[x] <= time){
			sum += array[x];
			counter++;
		}else break;
	}
	return counter;
}
int bothSequenceFinding(int array[],int mid,int length,int time){
	int sum = array[mid];
	int counter  = 0;
	for(int x = mid-1,y = mid+1;x>=0,y<length;x--,y++){
		if(sum+ array[x]+ array[y] <= time){
			sum += array[x]+ array[y];
			counter+=2;
		}else break;
	}
	return counter;

}
int leftsequenceFinding(int array[],int index,int length,int time){
	int sum = 0;int counter = 0;
	for(int x = index;x>=0;x--){
		if(sum+ array[x] <= time){
			sum += array[x];
			counter++;
		}else break;
	}
	return counter;
}
int binarySearch(int sumArray[],int array[],int length,int time){
	int high = length;
	int max = 0;
	int hold[3];
	int low  = 0;
	int mid;
	while(low <= high){
	    mid = (high + low)/2;
		if(sumArray[mid] == time)return mid+1;
	    else if(sumArray[mid]>time){
	    	hold[0] = RightsequenceFinding(array, mid, length, time);
	    	hold[1] =  leftsequenceFinding( array, mid, length, time);
	    	hold[2] =  bothSequenceFinding( array, mid, length, time);
	    	for(int x = 0;x<3;x++){
	    		if(hold[x]>max)max = hold[x];
			}
			high = mid - 1;
		}
		else{
			hold[0] = RightsequenceFinding(array,mid,length,time);
	    	hold[1] =  leftsequenceFinding(array,mid,length,time);
	    	hold[2] =  bothSequenceFinding(array,mid,length,time);
			for(int x = 0;x<3;x++){
	    		if(hold[x]>max)max = hold[x];
			}
			low = mid + 1;
		}
	}
 	return max;
}
int main(){
	int length ,time,sum = 0;
	scanf("%d %d",&length,&time);
	int array[length];
	int sumArray[length];
	for(int x = 0;x<length;x++)scanf("%d",&array[x]);
	sumArray[0] = array[0];
	for(int x = 1;x<length;x++)sumArray[x] = sumArray[x-1]+array[x];
    printf("%d", binarySearch(sumArray,array,length,time));
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;int ftime;
    cin >> n >> ftime;
    int books[n];
    for(int i = 0;i<n;++i)cin >> books[i];
    int count = 0;
    for(int i = 0;i<n;++i){
        if(ftime == 0)break;
        else if(ftime-books[i]>=0){
            count++;
            ftime-=books[i];
        }
    }
    cout << count;

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll length,time,max = 0, prev = 0;
	scanf("%lld %lld",&length,&time);
	ll array[length];
	ll hold = 0;
	for(ll x = 0;x<length;x++)scanf("%d",&array[x]);
	ll counter = 0,sum = 0;
	for(ll x = 0;x<length;x++){
		if(sum + array[x]<= time){
			sum += array[x];
			counter++;
			hold = counter;
		}
		else{
			sum = 0;
			counter = 0;
			x = prev++;
		}
		if(hold > max)max = hold;

	}
	printf("%lld",max);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int length,time,max = 0, prev = 0;
	scanf("%d %d",&length,&time);
	int array[length];
	int hold = 0;
	for(int x = 0;x<length;x++)scanf("%d",&array[x]);
	int counter = 0,sum = 0;
	for(int x = 0;x<length;x++){
		if(sum + array[x]<= time){
			sum += array[x];
			counter++;
			hold = counter;
		}
		else{
			sum = 0;
			counter = 0;
			x = prev++;
		}
		if(hold > max)max = hold;

	}
	printf("%d",max);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define max 9999999
#define ll long long
ll consi[max];
ll arr[max];
void generate(ll length){
    ll sum = 0;
    for(ll i = 1;i<=length;++i){
        sum+=arr[i];
        consi[i] = sum;
    }
}
ll max_val(ll a,ll b){
    if(a>b)return a;
    return b;
}
ll  solve(ll length,ll ftime){
    ll start = 0;
    ll end = 1;
    ll sln = 0;
    while(end<=length){
        ll cons = consi[end]-consi[start];
        if(cons>ftime){
             start++;
        }
        else if(cons<=ftime){
            sln = max_val(sln,end-start);
            end++;
        }
    }
    return sln;
}
int main(){
    ll length;
    ll ftime;
    cin >> length >> ftime;
    for(ll i = 1;i<=length;++i)cin >> arr[i];
    generate(length);
    cout << solve(length,ftime);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll RightsequenceFinding(ll array[],ll index,ll length,ll time){
	ll sum = 0;int counter = 0;
	for(ll x = index;x<length;x++){
		if(sum+ array[x] <= time){
			sum += array[x];
			counter++;
		}else break;
	}
	return counter;
}
ll bothSequenceFinding(ll array[],ll mid,ll length,ll time){
	ll sum = array[mid];
	ll counter  = 0;
	for(ll x = mid-1,y = mid+1;x>=0,y<length;x--,y++){
		if(sum+ array[x]+ array[y] <= time){
			sum += array[x]+ array[y];
			counter+=2;
		}else break;
	}
	return counter;

}
ll leftsequenceFinding(ll array[],ll index,ll length,ll time){
	ll sum = 0;ll counter = 0;
	for(ll x = index;x>=0;x--){
		if(sum+ array[x] <= time){
			sum += array[x];
			counter++;
		}else break;
	}
	return counter;
}
ll binarySearch(ll sumArray[],ll array[],ll length,ll time){
	ll high = length;
	ll max = 0;
	ll hold[3];
	ll low  = 0;
	ll mid;
	while(low <= high){
	    mid = (high + low)/2;
		if(sumArray[mid] == time)return mid+1;
	    else if(sumArray[mid]>time){
	    	hold[0] = RightsequenceFinding(array, mid, length, time);
	    	hold[1] =  leftsequenceFinding( array, mid, length, time);
	    	hold[2] =  bothSequenceFinding( array, mid, length, time);
	    	for(int x = 0;x<3;x++){
	    		if(hold[x]>max)max = hold[x];
			}
			high = mid - 1;
		}
		else{
			hold[0] = RightsequenceFinding(array,mid,length,time);
	    	hold[1] =  leftsequenceFinding(array,mid,length,time);
	    	hold[2] =  bothSequenceFinding(array,mid,length,time);
			for(int x = 0;x<3;x++){
	    		if(hold[x]>max)max = hold[x];
			}
			low = mid + 1;
		}
	}
 	return max;
}
int main(){
	ll length ,time,sum = 0;
	scanf("%lld %lld",&length,&time);
	ll array[length];
	ll sumArray[length];
	for(ll x = 0;x<length;x++)scanf("%lld",&array[x]);
	sumArray[0] = array[0];
	for(ll x = 1;x<length;x++)sumArray[x] = sumArray[x-1]+array[x];
    printf("%lld", binarySearch(sumArray,array,length,time));
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int books,times;
	cin >> books >> times;
	int array[books];
	for(int i = 0;i<books;++i){
		cin >> array[i];
	}
	sort(array,array+books);
	int sln = 0;
	int ctr = 0;
	for(int i = 0;i<books;++i){
		if(sln+array[i]<=times){
			sln+=array[i];
			ctr++;
		}
	}
	cout << ctr;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int max(int a,int b){
	return ((a>b)?a:b);
}
int main(){
	int books,times;
	scanf("%d %d",&books,&times);
	int array[books];
	for(int i = 0;i<books;++i){
		scanf("%d",&array[i]);
	}
	int sln = 0;
	int final = 0;
	for(int i = 0;i<books;++i){
		int ctr = 0,sln = 0;
		for(int j = i;j<books;++j){
			if(sln+array[j]<=times){
				ctr++;
				sln+=array[j];
			}
			else break;
		}
		final = max(ctr,final);
	}
	cout << final;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int length;
	int time ;
	cin >> length >> time;
	int array[length];
	for(int i = 0;i<length;++i){
		cin >> array[i];
	}
	int books = 0;
	for(int i = 0;i<length;++i){
		if(array[i]<=time && time!=0){
			++books;
			time-=array[i];
		}
		if(time<=0)break;
	}
	cout << books;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;int ftime;
    cin >> n >> ftime;
    int books[n];
    int totalTime = ftime;
    for(int i = 0;i<n;++i)cin >> books[i];
    int count = 0;
    int sln = 0;
    for(int i = 0;i<n;++i){
        count = 0;
        ftime = totalTime;
        for(int j =i;j<n;++j){
            if(ftime == 0)break;
            else if(ftime-books[j]>=0){
                count++;
                ftime-=books[j];
            }
            else if(books[j]>ftime)break;
            else continue;
        }
        if(sln<count)sln = count;
    }
    cout << sln;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int books,times;
	cin >> books >> times;
	int array[books];
	for(int i = 0;i<books;++i){
		cin >> array[i];
	}
	int sln = 0;
	int ctr = 0;
	for(int i = 0;i<books;++i){
		if(sln+array[i]<=times){
			sln+=array[i];
			ctr++;
		}
	}
	cout << ctr;
	return 0;
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
	int counter;
	int range,time;
	cin >> range >> time;
	int array[range];
	for(int x = 0;x<range;x++)cin >> array[x];
	sort(array,array+range);
	for(int x = 0;x<range;x++){
		if(array[x]<=time){
			counter++;
			time-=array[x];
		}
		if(time<array[x])break;
	}
	cout << counter;

	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int book, time;
	cin >> book >> time;
	vector<int>ds;
	ds.resize(book);
	for (int i = 0; i < book; i++)
	{
		cin >> ds[i];
	}
	int  max = 0;
	for (int j = 0; j < ds.size(); j++)
	{
		if (ds[j]>time) continue;
		int tong = ds[j];
		int dem = 1;
		for (int k = j + 1; k < ds.size(); k++)
		{
			if (tong + ds[k] <= time)
			{
				dem++;
				tong += ds[k];
			}
			else  break;
		}
		if (dem >= max) max = dem;
	}
	cout << max;
	ds.clear();
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int book, time, max = 0, dem = 0, tong = 0, flag =0;
	cin >> book >> time;
	vector<int>ds;
	ds.resize(book);
	for (int l = 0; l < book; l++)
	{
		cin >> ds[l];
		if (tong + ds[l] <= time && flag ==0)
		{
			tong += ds[l];
			dem++;
		}
		else flag = 1;
	}
	max = dem;
	for (int i = 1; i < book; i++)
	{
		dem--;
		tong -= ds[i-1];
		for (int k = i + dem; k < book; k++)
		{
			if (tong + ds[k] <= time)
			{
				dem++;
				tong += ds[k];
			}
			else  break;
		}
		if (dem > max) max = dem;
	}
	cout << max;
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int book, time;
	cin >> book >> time;
	vector<int>ds;
	for (int i = 0; i < book; i++)
	{
		int x;
		cin >> x;
		ds.push_back(x);
	}
	int  max = 0;
	for (int j = 0; j < ds.size(); j++)
	{
		int tong = ds[j];
		int dem = 1;
		for (int k = j + 1; k < ds.size(); k++)
		{
			if (tong + ds[k] <= time)
			{
				dem++;
				tong += ds[k];
			}
			else break;
		}
		if (dem >= max) max = dem;
	}
	cout << max;
	ds.clear();
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int book, time;
	cin >> book >> time;
	vector<int>ds;
	for (int i = 0; i < book; i++)
	{
		int x;
		cin >> x;
		ds.push_back(x);
	}
	int  max = 0;
	for (int j = 0; j < ds.size(); j++)
	{
		if (ds[j]>time) continue;
		int tong = ds[j];
		int dem = 1;
		for (int k = j + 1; k < ds.size(); k++)
		{
			if (tong + ds[k] <= time)
			{
				dem++;
				tong += ds[k];
			}
			else  break;
		}
		if (dem >= max) max = dem;
	}
	cout << max;
	ds.clear();
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int book, time, max = 0, flag = 1, dec = 0, k = 1;
	cin >> book >> time;
	vector<int>ds;
	int x;
	cin >> x;
	ds.push_back(x);
	while (ds.size() != 0)
	{
		if (ds[0] > time)
		{
			if ((ds.size() == 1) && (flag < book))
			{
				int z;
				cin >> z;
				ds.push_back(z);
			}
			ds.erase(ds.begin());
			dec++;
			continue;
		}
		int tong = ds[0];
		for (; k < book - dec ; k++)
		{
			if (flag < book)
			{
				int y;
				cin >> y;
				ds.push_back(y);
				flag++;
			}
			if (tong + ds[k] <= time)
				tong += ds[k];
			else  break;
		}
		if (k >= max) max = k;
		ds.erase(ds.begin());
		dec++;
	}
	cout << max;
	ds.clear();
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int book, time, max = 0, flag = 1, dec = 0;
	cin >> book >> time;
	vector<int>ds;
	int x;
	cin >> x;
	ds.push_back(x);
	int tong = ds[0];
	while (ds.size() != 0)
	{
		if (ds.size() < max) break;
		if (ds[0] > time)
		{
			if ((ds.size() == 1) && (flag < book))
			{
				int z;
				cin >> z;
				ds.push_back(z);
			}
			ds.erase(ds.begin());
			dec++;
			continue;
		}
		int dem = 1;
		for (int k = dem; k < book - dec; k++)
		{
			if (flag < book)
			{
				int y;
				cin >> y;
				ds.push_back(y);
				flag++;
			}
			if (tong + ds[k] <= time)
			{
				dem++;
				tong += ds[k];
			}
			else  break;
		}
		if (dem >= max) max = dem;
		tong -= ds[0];
		ds.erase(ds.begin());
		dec++;
	}
	cout << max;
	ds.clear();
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int book, time, max = 0, flag = 1, dec = 0, dem = 1;
	cin >> book >> time;
	vector<int>ds;
	int x;
	cin >> x;
	ds.push_back(x);
	int tong = ds[0];
	while (ds.size() != 0)
	{
		if (ds.size() < max) break;
		if (ds[0] > time)
		{
			if ((ds.size() == 1) && (flag < book))
			{
				int z;
				cin >> z;
				ds.push_back(z);
			}
			ds.erase(ds.begin());
			dec++;
			continue;
		}

		for (int k = dem; k < book - dec; k++)
		{
			if (flag < book)
			{
				int y;
				cin >> y;
				ds.push_back(y);
				flag++;
			}
			if (tong + ds[k] <= time)
			{
				dem++;
				tong += ds[k];
			}
			else  break;
		}
		if (dem >= max) max = dem;
		dem--;
		tong -= ds[0];
		ds.erase(ds.begin());
		dec++;
	}
	cout << max;
	ds.clear();
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int book, time, max = 0, flag = 1, dec = 0;
	cin >> book >> time;
	vector<int>ds;
	int x;
	cin >> x;
	ds.push_back(x);
	while (ds.size() != 0)
	{
		if (ds[0] > time)
		{
			if ((ds.size() == 1) && (flag < book))
			{
				int z;
				cin >> z;
				ds.push_back(z);
			}
			ds.erase(ds.begin());
			dec++;
			continue;
		}
		int tong = ds[0], dem = 1;
		for (int k = 1; k < book - dec; k++)
		{
			if (flag < book)
			{
				int y;
				cin >> y;
				ds.push_back(y);
				flag++;
			}
			if (tong + ds[k] <= time)
			{
				dem++;
				tong += ds[k];
			}
			else  break;
		}
		if (dem >= max) max = dem;
		ds.erase(ds.begin());
		dec++;
	}
	cout << max;
	ds.clear();
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int book, time, max = 0, dec = 0, dem = 1;
	cin >> book >> time;
	vector<int>ds;
	for (int i = 0; i < book; i++)
	{
		int x;
		cin >> x;
		ds.push_back(x);
	}
	int tong = ds[0];
	while (ds.size() != 0)
	{
		if (ds[0] > time)
		{
			ds.erase(ds.begin());
			dec++;
			continue;
		}
		for (int k = dem; k < book - dec; k++)
		{
			if (tong + ds[k] <= time)
			{
				dem++;
				tong += ds[k];
			}
			else  break;
		}
		if (dem >= max) max = dem;
		dem--;
		tong -= ds[0];
		ds.erase(ds.begin());
		dec++;
		if (ds.size() < max) break;
	}
	cout << max;
	ds.clear();
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	long long book, time;
	cin >> book >> time;
	vector<int>ds;
	int  max = 0;
	for (int j = 0; j < book; j++)
	{
		int x;
		cin >> x;
		ds.push_back(x);
		if (ds[j]>time) continue;
		int tong = ds[j];
		int dem = 1;
		for (int k = j + 1; k < book; k++)
		{
			int y;
			cin >> y;
			ds.push_back(y);
			if (tong + ds[k] <= time)
			{
				dem++;
				tong += ds[k];
			}
			else  break;
		}
		if (dem >= max) max = dem;
	}
	cout << max;
	ds.clear();
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int book, time;
	cin >> book >> time;
	vector<int>ds;
	for (int i = 0; i < book; i++)
	{
		int x;
		cin >> x;
		if (x <= time) ds.push_back(x);
	}
	int  max = 0;
	for (int j = 0; j < ds.size(); j++)
	{
		int tong = ds[j];
		int dem = 1;
		for (int k = j + 1; k < ds.size() ; k++)
		{
			if (tong + ds[k] <= time)
			{
				dem++;
				tong += ds[k];
			}
			else break;
		}
		if (dem >= max) max = dem;
	}
	cout << max;
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	long int book, time;
	cin >> book >> time;
	vector<int>ds;
	long int  max = 0;
	for (int j = 0; j < book; j++)
	{
		int x;
		cin >> x;
		ds.push_back(x);
		if (ds[j]>time) continue;
		long int tong = ds[j];
		long int dem = 1;
		for (int k = j + 1; k < book; k++)
		{
			int y;
			cin >> y;
			ds.push_back(y);
			if (tong + ds[k] <= time)
			{
				dem++;
				tong += ds[k];
			}
			else  break;
		}
		if (dem >= max) max = dem;
	}
	cout << max;
	ds.clear();
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int book, time, max = 0, flag = 1, dec = 0;
	cin >> book >> time;
	vector<int>ds;
	int x;
	cin >> x;
	ds.push_back(x);
	while (ds.size() != 0)
	{
		if (ds[0] > time)
		{
			if ((ds.size() >= 2) || (flag == book))
			{
				ds.erase(ds.begin());
				dec++;
				continue;
			}
			else
			{
				int z;
				cin >> z;
				ds.push_back(z);
				ds.erase(ds.begin());
				dec++;
				continue;
			}
		}
		int tong = ds[0], dem = 1;
		for (int k = 1; k < book - dec; k++)
		{
			if (flag < book)
			{
				int y;
				cin >> y;
				ds.push_back(y);
				flag++;
			}
			if (tong + ds[k] <= time)
			{
				dem++;
				tong += ds[k];
			}
			else  break;
		}
		if (dem >= max) max = dem;
		ds.erase(ds.begin());
		dec++;
	}
	cout << max;
	ds.clear();
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int book, time;
	cin >> book >> time;
	vector<int>ds;
	for (int i = 0; i < book; i++)
	{
		int x;
		cin >> x;
		ds.push_back(x);
	}
	int  max = 0, dem = 0;
	for (int j = 0; j < ds.size(); j++)
	{
		int tong = ds[j];
		for (int k = j + 1; k < ds.size() ; k++)
		{
			if (tong + ds[k] <= time)
			{
				tong += ds[k];
			}
			else
			{
				dem = k - j;
				break;
			}
		}
		if (dem >= max) max = dem;
	}
	cout << max;
	ds.clear();
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int book, time;
	cin >> book >> time;
	vector<int>ds;
	for (int i = 0; i < book; i++)
	{
		int x;
		cin >> x;
		ds.push_back(x);
	}
	int  max = 0;
	for (int j = 0; j < ds.size(); j++)
	{
		int tong = ds[j];
		int dem = 1;
		for (int k = j + 1; k < ds.size(); k++)
		{
			if (ds[j]>time) break;
			else if (tong + ds[k] <= time)
			{
				dem++;
				tong += ds[k];
			}
			else break;
		}
		if (dem >= max) max = dem;
	}
	cout << max;
	ds.clear();
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int book, time, max = 0, dem = 0, tong = 0, flag =0;
	cin >> book >> time;
	vector<int>ds;
	ds.resize(book);
	for (int l = 0; l < book; l++)
	{
		cin >> ds[l];
		if (tong + ds[l] <= time && flag ==0)
		{
			tong += ds[l];
			dem++;
		}
		else flag = 1;
	}

	for (int i = 1; i < book; i++)
	{
		dem--;
		tong -= ds[i-1];
		for (int k = i + dem; k < book; k++)
		{
			if (tong + ds[k] <= time)
			{
				dem++;
				tong += ds[k];
			}
			else  break;
		}
		if (dem > max) max = dem;
	}
	cout << max;
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int book, time;
	cin >> book >> time;
	vector<int>ds;
	for (int i = 0; i < book; i++)
	{
		int x;
		cin >> x;
		ds.push_back(x);
	}
	int  max = 0, dem = 0;
	for (int j = 0; j < ds.size(); j++)
	{
		if (ds[j]>time) continue;
		int tong = ds[j];
		int dem = 1;
		for (int k = j + 1; k < ds.size(); k++)
		{
			if (tong + ds[k] <= time)
			{
				tong += ds[k];
			}
			else
			{
				dem = k - j;
				break;
			}
		}
		if (dem >= max) max = dem;
	}
	cout << max;
	ds.clear();
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int book, time, max = 0, flag = 1, dec = 0;
	cin >> book >> time;
	vector<int>ds;
	int x;
	cin >> x;
	ds.push_back(x);
	while (ds.size() != 0)
	{
		if (ds[0] > time)
		{
			ds.erase(ds.begin());
			dec++;
			continue;
		}
		int tong = ds[0], dem = 1;
		for (int k = 1; k < book - dec; k++)
		{
			if (flag < book)
			{
				int y;
				cin >> y;
				ds.push_back(y);
				flag++;
			}
			if (tong + ds[k] <= time)
			{
				dem++;
				tong += ds[k];
			}
			else  break;
		}
		if (dem >= max) max = dem;
		ds.erase(ds.begin());
		dec++;
	}
	cout << max;
	ds.clear();
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int book, time, max = 0, flag = 1, dec = 0;
	cin >> book >> time;
	vector<int>ds;
	int x;
	cin >> x;
	ds.push_back(x);
	while (ds.size() != 0)
	{
		if (ds.size() < max) break;
		if (ds[0] > time)
		{
			if ((ds.size() == 1) && (flag < book))
			{
				int z;
				cin >> z;
				ds.push_back(z);
			}
			ds.erase(ds.begin());
			dec++;
			continue;
		}
		int tong = ds[0], dem = 1;
		for (int k = 1; k < book - dec; k++)
		{
			if (flag < book)
			{
				int y;
				cin >> y;
				ds.push_back(y);
				flag++;
			}
			if (tong + ds[k] <= time)
			{
				dem++;
				tong += ds[k];
			}
			else  break;
		}
		if (dem >= max) max = dem;
		ds.erase(ds.begin());
		dec++;
	}
	cout << max;
	ds.clear();
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int book, time, max = 0, flag = 1, dec = 0;
	cin >> book >> time;
	vector<int>ds;
	int x;
	cin >> x;
	ds.push_back(x);
	while (ds.size() != 0)
	{
		if (ds[0] > time)
		{
			if ((ds.size() == 1) && (flag < book))
			{
				int z;
				cin >> z;
				ds.push_back(z);
			}
			ds.erase(ds.begin());
			dec++;
			continue;
		}
		int tong = ds[0], dem = 0;
		for (int k = 1; k < book - dec ; k++)
		{
			if (flag < book)
			{
				int y;
				cin >> y;
				ds.push_back(y);
				flag++;
			}
			if (tong + ds[k] <= time)
			{
				tong += ds[k];
			}
			else
			{
				dem = k;
				break;
			}
		}
		if (dem >= max) max = dem;
		ds.erase(ds.begin());
		dec++;
	}
	cout << max;
	ds.clear();
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	long long book, time;
	cin >> book >> time;
	vector<int>ds;
	long long  max = 0;
	for (int j = 0; j < book; j++)
	{
		int x;
		cin >> x;
		ds.push_back(x);
		if (ds[j]>time) continue;
		long long tong = ds[j];
		long long dem = 1;
		for (int k = j + 1; k < book; k++)
		{
			int y;
			cin >> y;
			ds.push_back(y);
			if (tong + ds[k] <= time)
			{
				dem++;
				tong += ds[k];
			}
			else  break;
		}
		if (dem >= max) max = dem;
	}
	cout << max;
	ds.clear();
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int book, time, max = 0, flag = 1, dec = 0, dem = 1;
	cin >> book >> time;
	vector<int>ds;
	int x;
	cin >> x;
	ds.push_back(x);
	int tong = ds[0];
	while (ds.size() != 0)
	{
		if (ds[0] > time)
		{
			if ((ds.size() == 1) && (flag < book))
			{
				int z;
				cin >> z;
				ds.push_back(z);
			}
			ds.erase(ds.begin());
			dec++;
			continue;
		}

		for (int k = dem; k < book - dec; k++)
		{
			if (flag < book)
			{
				int y;
				cin >> y;
				ds.push_back(y);
				flag++;
			}
			if (tong + ds[k] <= time)
			{
				dem++;
				tong += ds[k];
			}
			else  break;
		}
		if (dem >= max) max = dem;
		dem--;
		tong -= ds[0];
		ds.erase(ds.begin());
		dec++;
		if (ds.size() < max) break;
	}
	cout << max;
	ds.clear();
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	freopen("input.txt", "rt", stdin);
	int book, time, max = 0, dec = 0, dem = 1;
	cin >> book >> time;
	vector<int>ds;
	for (int i = 0; i < book; i++)
	{
		int x;
		cin >> x;
		ds.push_back(x);
	}
	int tong = ds[0];
	while (ds.size() != 0)
	{
		if (ds[0] > time)
		{
			ds.erase(ds.begin());
			dec++;
			continue;
		}
		for (int k = dem; k < book - dec; k++)
		{
			if (tong + ds[k] <= time)
			{
				dem++;
				tong += ds[k];
			}
			else  break;
		}
		if (dem >= max) max = dem;
		dem--;
		tong -= ds[0];
		ds.erase(ds.begin());
		dec++;
		if (ds.size() < max) break;
	}
	cout << max;
	ds.clear();
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int book, time, max = 0, dem = 0, tong = 0, flag =0;
	cin >> book >> time;
	vector<int>ds;
	ds.resize(book);
	for (int l = 0; l < book; l++)
	{
		cin >> ds[l];
		if (tong + ds[l] <= time && flag ==0)
		{
			tong += ds[l];
			dem++;
		}
		else flag = 1;
	}

	for (int i = 1; i < book; i++)
	{
		dem--;
		tong -= ds[i];
		for (int k = i + dem; k < book; k++)
		{
			if (tong + ds[k] <= time)
			{
				dem++;
				tong += ds[k];
			}
			else  break;
		}
		if (dem > max) max = dem;
	}
	cout << max;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n,t;cin>>n>>t;
  int t1=t;
  int s[n];
  for(int i=0;i<n;i++)
  cin>>s[i];
  int f=0,f1=0,a=0;
  for(int i=0;i<n;i++){
    if(s[i]<=t){
      f++;
      t-=s[i];
    }
  else{
f1=max(f1,f);
f--;
t+=s[a];
if(s[i]<=t)
{
  f++;
  t-=s[i];
}
a++;
    }
 f1=max(f1,f);
  }
  cout<<f1;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,t;cin>>n>>t;
  int t1=t;
  int s[n];
  for(int i=0;i<n;i++)
  cin>>s[i];
  int f=0,f1=0;
  for(int i=0;i<n;i++){
    if(s[i]<=t){
      f++;
      t-=s[i];
    }else
    break;
  }
  for(int i=n-1;i>=0;i--){
    if(s[i]<=t1){
      f1++;
      t1-=s[i];
    }else
    break;
  }
  cout<<max(f1,f);
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,t;cin>>n>>t;
  int t1=t;
  int s[n];
  for(int i=0;i<n;i++)
  cin>>s[i];
  sort(s,s+n);
  int f=0,f1=0;
  for(int i=0;i<n;i++){
if(s[i]<=t)
{
  f++;
  t-=s[i];
}
  }for(int i=n-1;i>=0;i--){
if(s[i]<=t1)
{
  f1++;
  t1-=s[i];
}
  }
  cout<<max(f,f1);
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,y,t=0,c=0,f=0,f1=0;
	cin>>x>>y;
	int a[x];
	for(int i=0;i<x;i++)
	cin>>a[i];
	for(int i=0;i<x;i++){
		c+=a[i];
	if(c<=y)
	f++;
	else{
		c-=a[t];
		t++;
	}
	f1=max(f1,f);
	}
	cout<<f1;

}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,t;cin>>n>>t;
  int t1=t;
  int s[n];
  for(int i=0;i<n;i++)
  cin>>s[i];
  int f=0,f1=0;
  for(int i=0;i<n;i++){
if(s[i]<=t)
{
  f++;
  t-=s[i];
}
  }for(int i=n-1;i>=0;i--){
if(s[i]<=t1)
{
  f1++;
  t1-=s[i];
}
  }
  cout<<max(f,f1);
}


#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
ll a,b;
bool can(ll num,ll arr[]){
  ll sum=0;
  for(int i=0;i<num;i++)
  sum+=arr[i];
  if(sum<=b)
  return 1;
  for(int i=0;i<a-num;i++){
    sum-=arr[i];
    sum+=arr[i+num];
    if(sum<=b)
  return 1;
  }
  return 0;
}
int main() {
  cin>>a>>b;
  ll s[a];
for(int i=0;i<a;i++)
cin>>s[i];
ll l=1,r=a,mid,ans=0;
while(r>=l){
  mid=l+(r-l)/2;
if(can(mid,s)){
  ans=mid;
  l=mid+1;
}else
r=mid-1;
}
cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n,t;cin>>n>>t;
  int t1=t;
  int s[n];
  for(int i=0;i<n;i++)
  cin>>s[i];
  int f=0,f1=0,a=0;
  ll sum=0;
 for(int i=0;i<n;i++){
   sum+=s[i];
   if(sum<=t)
   f++;
   else{
     sum-=s[a];
     a++;
   }
   f1=max(f1,f);
 }
 cout<<f1;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;cin>>n>>k;
	int s[n];
	long long sum=0;
	for(int i=0;i<n;i++){
		cin>>s[i];
		sum+=s[i];
	}
	int a=0,f=0,b=n-1;
	for(int i=0;i<n;i++){
		if(sum>k){
			if(s[a]>=s[b])
			{
				sum-=s[a];
			a++;
			f++;
			}else{
				sum-=s[b];
				b--;
				f++;
			}
		}
	}
	cout<<n-f;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,t;cin>>n>>t;
  int t1=t;
  int s[n];
  for(int i=0;i<n;i++)
  cin>>s[i];
  int f=0,f1=0;
  for(int i=0;i<n;i++){
if(s[i]<=t)
{
  f++;
  t-=s[i];
}else
break;
  }
 for(int i=n-1;i>=0;i--){
if(s[i]<=t1)
{
  f1++;
  t1-=s[i];
}else break;
  }
 cout<<max(f,f1);
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,t;cin>>n>>t;
  int s[n];
  for(int i=0;i<n;i++)
  cin>>s[i];
  int f=0,f1=0;
  long long sum=0;
  for(int i=0;i<n;i++){
    sum=0;f=0;
for(int y=i;y<n;y++){
sum+=s[y];
if(sum>t)
break;
else
f++;
}
f1=max(f1,f);
  }
  cout<<f1;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,t;cin>>n>>t;
  int s[n];
  for(int i=0;i<n;i++)
  cin>>s[i];
  sort(s,s+n);
  int f=0;
  for(int i=0;i<n;i++){
if(s[i]<=t)
{
  f++;
  t-=s[i];
}
  }
  cout<<f;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n,t;cin>>n>>t;
  int t1=t;
  int s[n];
  for(int i=0;i<n;i++)
  cin>>s[i];
  int f=0,f1=0,a=0;
  ll sum=0;
 for(int i=0;i<n;i++){
   if(s[i]<=t){
     t-=s[i];
     f++;
   }else{
     t+=s[a];
     a++;
     if(s[i]<=t)
     t-=s[i];
     else
     {
       t=t1;
       f=0;
     }
   }
   f1=max(f1,f);
 }
 cout<<f1;
}


#include <iostream>

using namespace std;
long long m,n,a[10000];
long long tong=0,dem=1;
long long j=1,rs;
void nhap()
{  ios::sync_with_stdio(false); cin.tie(0);
    cin>>m>>n;
    for(long long i=1; i<=m; i++)
        cin>>a[i];

}
void xuly()
{
    if(m==1&&a[1]<n)
        cout<<"1";
    else if(m==1&&a[1]>n)
        cout<<"0";
    else
    {
        tong=a[1];
        for(long long i=2; i<=m; i++)
        {
            if (tong<=n)
            {
                tong+=a[i];
                dem++;
            }
            else
            {
                while(tong>n)
                {
                    tong-=a[j];
                    j++;
                    dem--;
                }
                if(dem>rs)
				  rs=dem;
            }

        }
        cout<<rs;
    }
}
int main()
{
    nhap();
    xuly();
    return 0;
}


#include <iostream>

using namespace std;
long long m,n,a[10000];
long long tong=0,dem=1;
long long j=1,rs;
void nhap()
{
    cin>>m>>n;
    for(long long i=1; i<=m; i++)
        cin>>a[i];

}
void xuly()
{
    if(m==1&&a[1]<n)
        cout<<"1";
    else if(m==1&&a[1]>n)
        cout<<"0";
    else
    {
        tong=a[1];
        for(long long i=2; i<=m; i++)
        {
            if (tong<=n)
            {
                tong+=a[i];
                dem++;
            }
            else
            {
                    tong-=a[j];
                    j++;
                    dem--;
            }
                if(dem>rs)
				  rs=dem;

        }
        cout<<rs;
    }
}
int main()
{
    nhap();
    xuly();
    return 0;
}


#include <cstdio>

int main(){

    int n; long t; scanf("%d %ld", &n, &t);
    long *minutes = new long[n];
    long totalTime = 0;
    for(int k = 0; k < n; k++){scanf("%ld", minutes + k); totalTime += minutes[k];}

    long start(0), finish(0), currentSum(0), output(0);

    while(finish < n){
        currentSum += minutes[finish++];
        while(currentSum > t){currentSum -= minutes[start++];}
        if(output < finish - start){output = finish - start;}
    }

    printf("%ld\n", output);

    delete[] minutes;
    return 0;
}


#include <iostream>

using namespace std;
unsigned long long m,n,a[100000];
unsigned long long tong=0,dem=1;
unsigned long long j=1,rs;
void nhap()
{   ios::sync_with_stdio(false); cin.tie(0);
    cin>>m>>n;
    for(long long i=1; i<=m; i++)
        cin>>a[i];

}
void xuly()
{
    if(m==1&&a[1]<n)
        cout<<"1";
    else if(m==1&&a[1]>n)
        cout<<"0";
    else
    {
        tong=a[1];
        for(unsigned long long i=2; i<=m; i++)
        {
            if (tong<=n)
            {
                tong+=a[i];
                dem++;

            }
            if (tong>n)
            {    if(dem>rs)
				  rs=dem-1;
                while(tong>n)
                {
                    tong-=a[j];
                    j++;
                    dem--;
                }

            }
            if(dem>rs)
				rs=dem;
        }
        cout<<rs;
    }
}
int main()
{
    nhap();
    xuly();
    return 0;
}


#include <iostream>

using namespace std;
long long m,n,a[100000];
long long tong=0,dem=1;
long long j=1,rs=0,i=1,cur;
void nhap()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>m>>n;
    for(long long i=1; i<=m; i++)
        cin>>a[i];

}
void xuly()
{
    while(i<=m)
    {
        tong+=a[i++];
        while(tong>n)
        {
            tong-=a[j++];
        }
        if(rs<i-j)
            rs=i-j;
    }
cout<<rs;
}
int main()
{
    nhap();
    xuly();
    return 0;
}


#include <iostream>

using namespace std;
long long m,n,a[100000];
long long tong=0,dem=1;
long long j=1,rs;
void nhap()
{   ios::sync_with_stdio(false); cin.tie(0);
    cin>>m>>n;
    for(long long i=1; i<=m; i++)
        cin>>a[i];

}
void xuly()
{
    if(m==1&&a[1]<n)
        cout<<"1";
    else if(m==1&&a[1]>n)
        cout<<"0";
    else
    {
        tong=a[1];
        for(long long i=2; i<=m; i++)
        {
            if (tong<=n)
            {
                tong+=a[i];
                dem++;

            }
            if (tong>n)
            {    if(dem>rs)
				  rs=dem-1;
                while(tong>n)
                {
                    tong-=a[j];
                    j++;
                    dem--;
                }

            }
            if(dem>rs)
				rs=dem;

        }
        cout<<rs;
    }
}
int main()
{
    nhap();
    xuly();
    return 0;
}


#include <iostream>

using namespace std;
long long m,n,a[10000];
long long tong=0,dem=1;
long long j=1,rs;
void nhap()
{   ios::sync_with_stdio(false); cin.tie(0);
    cin>>m>>n;
    for(long long i=1; i<=m; i++)
        cin>>a[i];

}
void xuly()
{
    if(m==1&&a[1]<n)
        cout<<"1";
    else if(m==1&&a[1]>n)
        cout<<"0";
    else
    {
        tong=a[1];
        for(long long i=2; i<=m; i++)
        {
            if (tong<=n)
            {
                tong+=a[i];
                dem++;

            }
            if (tong>n)
            {    if(dem>rs)
				  rs=dem-1;
                while(tong>n)
                {
                    tong-=a[j];
                    j++;
                    dem--;
                }

            }
            if(dem>rs)
				rs=dem;

        }
        cout<<rs;
    }
}
int main()
{
    nhap();
    xuly();
    return 0;
}


#include <iostream>

using namespace std;
long long m,n,a[10000];
long long tong=0,dem=1;
long long j=1,rs;
void nhap()
{
    cin>>m>>n;
    for(long long i=1; i<=m; i++)
        cin>>a[i];

}
void xuly()
{
    if(m==1&&a[1]<n)
        cout<<"1";
    else if(m==1&&a[1]>n)
        cout<<"0";
    else
    {
        tong=a[1];
        for(long long i=2; i<=m; i++)
        {
            if (tong<=n)
            {
                tong+=a[i];
                dem++;
            }
            else
            {   if(dem>rs)
				  rs=dem;
                while(tong>n)
                {
                    tong-=a[j];
                    j++;
                    dem--;
                }

            }

        }
        cout<<rs;
    }
}
int main()
{
    nhap();
    xuly();
    return 0;
}


#include <iostream>

using namespace std;
long long m,n,a[10000];
long long tong,dem=0;
long long j=1,rs;
void nhap()
{
    cin>>m>>n;
    for(long long i=1; i<=m; i++)
        cin>>a[i];

}
void xuly()
{
    tong=a[1];
    for(long long i=1; i<=m; i++)
    {
        if (tong<=n)
        {
            tong+=a[i];
            dem++;
        }
        else
        {
            while(tong>n)
            {
                tong-=a[j];
                j++;
            }
            if(dem>rs)
                rs=dem;
            dem=0;

        }
    }
    cout<<rs;
}
int main()
{
    nhap();
    xuly();
    return 0;
}


#include <iostream>

using namespace std;
long long m,n,a[10000];
long long tong=0,dem=0;
long long j=1,rs;
void nhap()
{
    cin>>m>>n;
    for(long long i=1; i<=m; i++)
        cin>>a[i];

}
void xuly()
{
    if(m==1&&a[1]<n)
        cout<<"1";
    else if(m==1&&a[1]>n)
        cout<<"0";
    else
    {
        tong=a[1];
        for(long long i=2; i<=m; i++)
        {
            while (tong<=n)
            {
                tong+=a[i];
                dem++;
            }
            while(tong>n)
            {
                tong-=a[j];
                j++;
            }
            if(dem>rs)
                rs=dem;
            dem=0;

        }
        cout<<rs;
    }
}
int main()
{
    nhap();
    xuly();
    return 0;
}


#include <iostream>

using namespace std;
long long m,n,a[10000];
long long tong=0,dem=0;
long long j=1,rs;
void nhap()
{
    cin>>m>>n;
    for(long long i=1; i<=m; i++)
        cin>>a[i];

}
void xuly()
{
    tong=a[1];
    for(long long i=2; i<=m; i++)
    {
        while (tong<=n)
        {
            tong+=a[i];
            dem++;
        }
        while(tong>n)
            {
                tong-=a[j];
                j++;
            }
            if(dem>rs)
		    rs=dem;
            dem=0;

    }
    cout<<rs;
}
int main()
{
    nhap();
    xuly();
    return 0;
}


#include <iostream>

using namespace std;
long long m,n,a[10000];
long long tong=0,dem=1;
long long j=1,rs;
void nhap()
{
    cin>>m>>n;
    for(long long i=1; i<=m; i++)
        cin>>a[i];

}
void xuly()
{
    if(m==1&&a[1]<n)
        cout<<"1";
    else if(m==1&&a[1]>n)
        cout<<"0";
    else
    {
        tong=a[1];
        for(long long i=2; i<=m; i++)
        {
            if (tong<=n)
            {
                tong+=a[i];
                dem++;
            }
            else
            {
                while(tong>n)
                {
                    tong-=a[j];
                    j++;
                    dem--;
                }
                if(dem>rs)
				  rs=dem;
            }

        }
        cout<<rs;
    }
}
int main()
{
    nhap();
    xuly();
    return 0;
}


#include <iostream>

using namespace std;
long int m,n,a[100000];
long int tong=0;
long int j=0,rs=0,i=0;
void nhap()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>m>>n;
    for(long long i=0; i<m; i++)
        cin>>a[i];

}
void xuly()
{
    while(i<m)
    {
        tong+=a[i++];
        while(tong>n)
        {
            tong-=a[j++];
        }
        if(rs<i-j)
            rs=i-j;
    }
cout<<rs;
}
int main()
{
    nhap();
    xuly();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long int n;
long long int partialsum(long long int *arr, long long int k)
{
    long long int minsum = LONG_LONG_MAX;
    long long int tempsum = 0;
    for(int i =0; i<k; i++)
     {

         tempsum += arr[i];
         //cout<<"Initial temp sum = "<<tempsum<<endl;
     }
    minsum = tempsum;
    for(int i = k; i<n; i++)
    {
        tempsum -= arr[i-k];
        tempsum += arr[i];
        minsum = min(tempsum,minsum);
        //cout<<"Temp Sum = "<<tempsum<<endl<<"Minsum = "<<minsum<<endl;
    }
    return minsum;
}
int main()
{
    long long int t;
    cin>>n>>t;
    long long int arr[n];
    for(int i = 0; i<n; i++)
        cin>>arr[i];
    //cout<<"Check method "<< partialsum(arr, 3)<<endl;
    long long int ans = LONG_LONG_MIN;
    long long int mid = n/2;
    long long int left = 0;
    long long int right = n;
    long long int oldleft=-1;
    long long int oldright=-1;
    while(oldleft != left || oldright != right)
    {
            oldleft = left;
            oldright = right;
            if(right - left == 1 && partialsum(arr,right) <=t)
            {
                ans = max(ans,right);
            }
            if(partialsum(arr,mid) == t)
            {
                cout<<mid;
                //cout<<"Did we come here"<<endl;
                exit(0);
            }
            if(partialsum(arr,mid) > t)
            {
                right = mid;
                mid = (left + right)/2;

            }
            if(partialsum(arr,mid) <t)
            {
                ans = max(ans,mid);
                left = mid;
                mid = (left+ right)/2;

            }
             //cout<<"Left = "<<left<<endl<<"Mid = "<<mid<<endl<<"Right = "<<right<<endl;

    }
    cout<<ans<<endl;

}


#include<bits/stdc++.h>
using namespace std;
struct node
{
    int x, y;
};
bool compare(node a, node b)
{
    return b.y > a.y;
}
int main()
{
    long long int n,t;
    cin>>n>>t;
    node arr[t];
    int M[n];
    long long int lshift = 0;
    long long int rshift = 0;
    for(int i = 0; i<n; i++)
        M[i] = 0;
    for(int i = 0; i<n; i++)
    {
        arr[i].x = i+1;
        cin>>arr[i].y;
        M[0] += arr[i].y;
    }
    for(int i = 1; i<n; i++)
    {
        if(arr[lshift].y > arr[n-1-rshift].y)
        {
                M[i] = M[i-1] - arr[lshift].y;
                lshift++;
        }
        else
        {
            M[i] = M[i-1] - arr[n-1-rshift].y;
            rshift++;
        }
    }
    for(int i = 0; i<n; i++);
       // cout<<M[i]<<endl;
    for(int i = 0; i<n; i++)
    {
        if(t>=M[i])
        {
            cout<<n-i;
            exit(0);
        }
    }
    cout<<0;
}


#include<bits/stdc++.h>
using namespace std;
long long int n;
long long int partialsum(long long int *arr, long long int k)
{
    long long int minsum = LONG_LONG_MAX;
    long long int tempsum = 0;
    for(int i = 0; i<n-k+1; i++)
    {
        for(int j = i; j<i+k; j++)
        {
            tempsum+= arr[j];
        }
        if(tempsum <minsum)
            minsum = tempsum;
        tempsum = 0;
    }
    return minsum;
}
int main()
{
    long long int t;
    cin>>n>>t;
    long long int arr[n];
    for(int i = 0; i<n; i++)
        cin>>arr[i];
    long long int ans;
    long long int mid = n/2;
    long long int left = 0;
    long long int right = n;
    long long int oldleft=-1;
    long long int oldright=-1;
    while(left <right  && oldleft != left && oldright != right)
    {
            oldleft = left;
            oldright = right;
            if(partialsum(arr,mid) == t)
            {
                cout<<mid;
                exit(-1);
            }
            if(partialsum(arr,mid) > t)
            {
                right = right/2;
                mid = (left + right)/2;
            }
            if(partialsum(arr,mid) <t)
            {
                left = mid;
                mid = left/2 + right/2;

            }
    }
    cout<<mid<<endl;

}


#include<bits/stdc++.h>
using namespace std;
struct node
{
    int x, y;
};
bool compare(node a, node b)
{
    return b.y > a.y;
}
int main()
{
    long long int n,t;
    cin>>n>>t;
    node arr[t];
    int M[n];
    long long int lshift = 0;
    long long int rshift = 0;
    for(int i = 0; i<n; i++)
        M[i] = 0;
    for(int i = 0; i<n; i++)
    {
        arr[i].x = i+1;
        cin>>arr[i].y;
        M[0] += arr[i].y;
    }
    for(int i = 1; i<n; i++)
    {
        if(arr[lshift].y > arr[n-1-rshift].y)
        {
                M[i] = M[i-1] - arr[lshift].y;
                lshift++;
        }
        else
        {
            M[i] = M[i-1] - arr[n-1-rshift].y;
            rshift++;
        }
    }
    for(int i = 0; i<n; i++);
       // cout<<M[i]<<endl;
    for(int i = 0; i<n; i++)
    {
        if(t>=M[i])
        {
            cout<<n-i;
            exit(0);
        }

    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    long long int t;
    cin>>n>>t;
    long long int arr[n];
    long long int M[n];
    long long int lshift = 0;
    long long int rshift = 0;
    for(long long int i = 0; i<n; i++)
       M[i] = 0;
    for(long long int i = 0; i<n; i++)
    {
        cin>>arr[i];
        M[0] += arr[i];
    }
    for(long long int i = 1; i<n; i++)
    {
        if(arr[lshift] > arr[n-1-rshift])
        {
                M[i] = M[i-1] - arr[lshift];
                lshift++;
        }
        else
        {
            M[i] = M[i-1] - arr[n-1-rshift];
            rshift++;
        }
    }
    for(long long int i = 0; i<n; i++);
        //cout<<M[i]<<endl;
    for(long long int i = 0; i<n; i++)
    {
        if(t>=M[i])
        {
            cout<<n-i;
            exit(0);
        }
    }
    cout<<0;
}


#include<bits/stdc++.h>
using namespace std;
long long int n;
long long int partialsum(long long int *arr, long long int k)
{
    long long int minsum = LONG_LONG_MAX;
    long long int tempsum = 0;
    for(int i = 0; i<n-k+1; i++)
    {
        for(int j = i; j<i+k; j++)
        {
            tempsum+= arr[j];
        }
        if(tempsum <minsum)
            minsum = tempsum;
        tempsum = 0;
    }
    return minsum;
}
int main()
{
    long long int t;
    cin>>n>>t;
    long long int arr[n];
    for(int i = 0; i<n; i++)
        cin>>arr[i];
    long long int ans = LONG_LONG_MIN;
    long long int mid = n/2;
    long long int left = 0;
    long long int right = n;
    long long int oldleft=-1;
    long long int oldright=-1;
    while(oldleft != left || oldright != right)
    {
            oldleft = left;
            oldright = right;
            if(right - left == 1 && partialsum(arr,right) <=t)
            {
                ans = max(ans,right);
            }
            if(partialsum(arr,mid) == t)
            {
                cout<<ans;
                cout<<"Did we come here"<<endl;
                exit(0);
            }
            if(partialsum(arr,mid) > t)
            {
                right = mid;
                mid = (left + right)/2;

            }
            if(partialsum(arr,mid) <t)
            {
                ans = max(ans,mid);
                left = mid;
                mid = left/2 + right/2;

            }

    }
    cout<<ans<<endl;

}


#include<bits/stdc++.h>
using namespace std;
long long int n;
long long int partialsum(long long int *arr, long long int k)
{
    long long int minsum = LONG_LONG_MAX;
    long long int tempsum = 0;
    for(int i = 0; i<n-k+1; i++)
    {
        for(int j = i; j<i+k; j++)
        {
            tempsum+= arr[j];
        }
        if(tempsum <minsum)
            minsum = tempsum;
        tempsum = 0;
    }
    return minsum;
}
int main()
{
    long long int t;
    cin>>n>>t;
    long long int arr[n];
    for(int i = 0; i<n; i++)
        cin>>arr[i];
    long long int ans;
    long long int mid = n/2;
    long long int left = 0;
    long long int right = n;
    long long int oldleft=-1;
    long long int oldright=-1;
    if(n==1)
    {
        if(partialsum(arr,1)<t)
        {
            cout<<1;
            exit(0);
        }
        else
        {
            cout<<0;
            exit(0);
        }
    }
    while(left <right  && oldleft != left && oldright != right)
    {
            oldleft = left;
            oldright = right;
            if(partialsum(arr,mid) == t)
            {
                cout<<mid;
                exit(0);
            }
            if(partialsum(arr,mid) > t)
            {
                right = mid;
                mid = (left + right)/2;

            }
            if(partialsum(arr,mid) <t)
            {
                left = mid;
                mid = left/2 + right/2;
                ans = mid;

            }
    }
    cout<<ans<<endl;

}


#include<bits/stdc++.h>
using namespace std;
long long int n;
long long int partialsum(long long int *arr, long long int k)
{
    long long int minsum = LONG_LONG_MAX;
    long long int tempsum = 0;
    for(int i = 0; i<n-k+1; i++)
    {
        for(int j = i; j<i+k; j++)
        {
            tempsum+= arr[j];
        }
        if(tempsum <minsum)
            minsum = tempsum;
        tempsum = 0;
    }
    return minsum;
}
int main()
{
    long long int t;
    cin>>n>>t;
    long long int arr[n];
    for(int i = 0; i<n; i++)
        cin>>arr[i];
    long long int ans;
    long long int mid = n/2;
    long long int left = 0;
    long long int right = n;
    long long int oldleft=-1;
    long long int oldright=-1;
    if(n==1)
    {
        if(partialsum(arr,1)<t)
        {
            cout<<1;
            exit(-1);
        }
        else
        {
            cout<<0;
            exit(-1);
        }
    }
    while(left <right  && oldleft != left && oldright != right)
    {
            oldleft = left;
            oldright = right;
            if(partialsum(arr,mid) == t)
            {
                cout<<mid;
                exit(-1);
            }
            if(partialsum(arr,mid) > t)
            {
                right = mid;
                mid = (left + right)/2;

            }
            if(partialsum(arr,mid) <t)
            {
                left = mid;
                mid = left/2 + right/2;
                ans = mid;

            }
    }
    cout<<ans<<endl;

}


#include<bits/stdc++.h>
using namespace std;
struct node
{
    int x, y;
};
bool compare(node a, node b)
{
    return b.y > a.y;
}
int main()
{
    long long int n,t;
    cin>>n>>t;
    node arr[t];
    for(int i = 0; i<n; i++)
    {
        arr[i].x = i+1;
        cin>>arr[i].y;
    }
    sort(arr, arr+n, compare);
    long long int counter = 0;
    for(int i = 0; i<n; i++)
    {

        if(t>= arr[i].y)
        {
             counter++;
             t -= arr[i].y;
        }
        else if(t<arr[i].y)
        {
            cout<<counter;
            exit(0);
        }
    }
    cout<<counter;
}


#include<bits/stdc++.h>
using namespace std;
long long int n;
long long int partialsum(long long int *arr, long long int k)
{
    long long int minsum = LONG_LONG_MAX;
    long long int tempsum = 0;
    for(int i = 0; i<n-k+1; i++)
    {
        for(int j = i; j<i+k; j++)
        {
            tempsum+= arr[j];
        }
        if(tempsum <minsum)
            minsum = tempsum;
        tempsum = 0;
    }
    return minsum;
}
int main()
{
    long long int t;
    cin>>n>>t;
    long long int arr[n];
    for(int i = 0; i<n; i++)
        cin>>arr[i];
    long long int ans = LONG_LONG_MIN;
    long long int mid = n/2;
    long long int left = 0;
    long long int right = n;
    long long int oldleft=-1;
    long long int oldright=-1;
    while(oldleft != left || oldright != right)
    {
            oldleft = left;
            oldright = right;
            if(right - left == 1 && partialsum(arr,right) <=t)
            {
                ans = max(ans,right);
            }
            if(partialsum(arr,mid) == t)
            {
                cout<<mid;
                //cout<<"Did we come here"<<endl;
                exit(0);
            }
            if(partialsum(arr,mid) > t)
            {
                right = mid;
                mid = (left + right)/2;

            }
            if(partialsum(arr,mid) <t)
            {
                ans = max(ans,mid);
                left = mid;
                mid = (left+ right)/2;

            }
             //cout<<"Left = "<<left<<endl<<"Mid = "<<mid<<endl<<"Right = "<<right<<endl;

    }
    cout<<ans<<endl;

}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define sq(a) (a)*(a)
#define debug(x) std::cerr<<#x<<"="<<x<<'\n'
#define text std::cerr<<"SacredCoupoid08\n"
#define endl '\n'
#define all(c) (c).begin(),(c).end()
#define U 1000000007
#define N 100005
#define sz(c) (int)c.size()
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pi;
#define cin std::cin
#define cout std::cout
#define vector std::vector
#define pb push_back
#define pv(x) for(auto y:x)    cerr<<y<<" ";    cerr<<'\n';
#define fr first
#define sc second
#define ppb pop_back
int main()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,s=0,l=0;
	int t;
	cin>>n>>t;
	vi a(n);
	for(auto &x:a) cin>>x;
	//sort(all(a));
	int i=0,j=n-1;
	//int p=i,q=j
	if(n!=1)
	{
		text;
		while(i!=n-2)
		{

			j=n-1;
			while(i<=j)
			{
				//debug(i);
			//debug(j);
			s=0;
				rep(p,i,j+1)
				{
					s+=a[p];
				}
				//debug(s);

				if(s<=t)
				{
					l=max(l,j+1-i);
					if(l==j+i+1){
					debug(i);
					debug(j);
				}

				}
				j--;
			}
			++i;
		}
}
	cout<<l<<endl;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define sq(a) (a)*(a)
#define debug(x) std::cerr<<#x<<"="<<x<<'\n'
#define text std::cerr<<"SacredCoupoid08\n"
#define endl '\n'
#define all(c) (c).begin(),(c).end()
#define U 1000000007
#define N 100005
#define sz(c) (int)c.size()
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pi;
#define cin std::cin
#define cout std::cout
#define vector std::vector
#define pb push_back
#define pv(x) for(auto y:x)    cerr<<y<<" ";    cerr<<'\n';
#define fr first
#define sc second
#define ppb pop_back
int main()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,s=0,l=0;
	int t;
	cin>>n>>t;
	vi a(n);
	for(auto &x:a) cin>>x;
	//sort(all(a));
	int i=0,j=n-1;
	//int p=i,q=j
	if(n!=1)
	{
		text;
		while(i!=n-2)
		{

			j=n-1;
			while(i<=j)
			{
				//debug(i);
			//debug(j);
			s=0;
				rep(p,i,j+1)
				{
					s+=a[p];
				}
				//debug(s);

				if(s<=t)
				{
					l=max(l,j+1-i);
					if(l==j+i+1){
					debug(i);
					debug(j);
				}

				}
				j--;
			}
			++i;
		}
}
else
{
	if(a[0]<=t)
	l=1;
}
	cout<<l<<endl;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define sq(a) (a)*(a)
#define debug(x) std::cerr<<#x<<"="<<x<<'\n'
#define text std::cerr<<"SacredCoupoid08\n"
#define endl '\n'
#define all(c) (c).begin(),(c).end()
#define U 1000000007
#define N 100005
#define sz(c) (int)c.size()
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pi;
#define cin std::cin
#define cout std::cout
#define vector std::vector
#define pb push_back
#define pv(x) for(auto y:x)    cerr<<y<<" ";    cerr<<'\n';
#define fr first
#define sc second
#define ppb pop_back
int main()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,s=0,i=0;
	int t;
	cin>>n>>t;
	vi a(n);
	for(auto &x:a) cin>>x;
	sort(all(a));
	for(auto x:a)
	{
		s+=x;
		debug(s);
		if(s>t)
		{
			s-=x;
			cout<<i<<endl;
			return 0;

		}
		++i;
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define sq(a) (a)*(a)
#define debug(x) std::cerr<<#x<<"="<<x<<'\n'
#define text std::cerr<<"SacredCoupoid08\n"
#define endl '\n'
#define all(c) (c).begin(),(c).end()
#define U 1000000007
#define N 100005
#define sz(c) (int)c.size()
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pi;
#define cin std::cin
#define cout std::cout
#define vector std::vector
#define pb push_back
#define pv(x) for(auto y:x)    cerr<<y<<" ";    cerr<<'\n';
#define fr first
#define sc second
#define ppb pop_back
int main()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,s=0,l=0;
	int t;
	cin>>n>>t;
	vi a(n);
	for(auto &x:a) cin>>x;
	//sort(all(a));
	int i=0,j=n-1;
	//int p=i,q=j
	while(i!=n-2)
	{

		j=n-1;
		while(i<=j)
		{
			//debug(i);
		//debug(j);
		s=0;
			rep(p,i,j+1)
			{
				s+=a[p];
			}
			//debug(s);

			if(s<=t)
			{
				l=max(l,j+1-i);
				if(l==j+i+1){
				debug(i);
				debug(j);
			}

			}
			j--;
		}
		++i;
	}
	cout<<l<<endl;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define sq(a) (a)*(a)
#define debug(x) std::cerr<<#x<<"="<<x<<'\n'
#define text std::cerr<<"SacredCoupoid08\n"
#define endl '\n'
#define all(c) (c).begin(),(c).end()
#define U 1000000007
#define N 100005
#define sz(c) (int)c.size()
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pi;
#define cin std::cin
#define cout std::cout
#define vector std::vector
#define pb push_back
#define pv(x) for(auto y:x)    cerr<<y<<" ";    cerr<<'\n';
#define fr first
#define sc second
#define ppb pop_back
int main()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,s=0,i=0;
	int t;
	cin>>n>>t;
	vi a(n);
	for(auto &x:a) cin>>x;
	//sort(all(a));
	for(auto x:a)
	{
		if(x<=t)
		{
			t-=x;
			i++;
		}
	}
	cout<<i<<endl;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define sq(a) (a)*(a)
#define debug(x) std::cerr<<#x<<"="<<x<<'\n'
#define text std::cerr<<"SacredCoupoid08\n"
#define endl '\n'
#define all(c) (c).begin(),(c).end()
#define U 1000000007
#define N 100005
#define sz(c) (int)c.size()
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pi;
#define cin std::cin
#define cout std::cout
#define vector std::vector
#define pb push_back
#define pv(x) for(auto y:x)    cerr<<y<<" ";    cerr<<'\n';
#define fr first
#define sc second
#define ppb pop_back
int main()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,s=0,i=0;
	int t;
	cin>>n>>t;
	vi a(n);
	for(auto &x:a) cin>>x;
	sort(all(a));
	for(auto x:a)
	{
		s+=x;
		debug(s);
		if(s>t)
		{
			s-=x;
			cout<<i<<endl;
			return 0;

		}
		++i;
	}
	cout<<sz(a)<<endl;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define sq(a) (a)*(a)
#define debug(x) std::cerr<<#x<<"="<<x<<'\n'
#define text std::cerr<<"SacredCoupoid08\n"
#define endl '\n'
#define all(c) (c).begin(),(c).end()
#define U 1000000007
#define N 100005
#define sz(c) (int)c.size()
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pi;
#define cin std::cin
#define cout std::cout
#define vector std::vector
#define pb push_back
#define pv(x) for(auto y:x)    cerr<<y<<" ";    cerr<<'\n';
#define fr first
#define sc second
#define ppb pop_back
int main()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,s=0,l=0;
	int t;
	cin>>n>>t;
	vi a(n);
	for(auto &x:a) cin>>x;
	//sort(all(a));
	int i=0,j=n-1;
	//int p=i,q=j
	if(i!=1){
	while(i!=n-2)
	{

		j=n-1;
		while(i<=j)
		{
			//debug(i);
		//debug(j);
		s=0;
			rep(p,i,j+1)
			{
				s+=a[p];
			}
			//debug(s);

			if(s<=t)
			{
				l=max(l,j+1-i);
				if(l==j+i+1){
				debug(i);
				debug(j);
			}

			}
			j--;
		}
		++i;
	}
}
	cout<<l<<endl;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define sq(a) (a)*(a)
#define debug(x) std::cerr<<#x<<"="<<x<<'\n'
#define text std::cerr<<"SacredCoupoid08\n"
#define endl '\n'
#define all(c) (c).begin(),(c).end()
#define U 1000000007
#define N 100005
#define sz(c) (int)c.size()
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pi;
#define cin std::cin
#define cout std::cout
#define vector std::vector
#define pb push_back
#define pv(x) for(auto y:x)    cerr<<y<<" ";    cerr<<'\n';
#define fr first
#define sc second
#define ppb pop_back
#define max(a,b) a=max(a,b)
int main()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,s=0,ans=0,j=0;
	int &sum=s;
	int t;
	cin>>n>>t;
	vi a(n);
	for(auto &x:a) cin>>x;
	//int i=0;
	rep(i,0,n)
	{
		if(a[i]+s<=t)
		{
			sum+=a[i];
			++i;
		}
		else
		{
			sum-=a[j];
			++j;
		}
		max(ans,i-j);

		i--;
	}
	cout<<ans<<endl;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define sq(a) (a)*(a)
#define debug(x) std::cerr<<#x<<"="<<x<<'\n'
#define text std::cerr<<"SacredCoupoid08\n"
#define endl '\n'
#define all(c) (c).begin(),(c).end()
#define U 1000000007
#define N 100005
#define sz(c) (int)c.size()
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pi;
#define cin std::cin
#define cout std::cout
#define vector std::vector
#define pb push_back
#define pv(x) for(auto y:x)    cerr<<y<<" ";    cerr<<'\n';
#define fr first
#define sc second
#define ppb pop_back
int main()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,s=0,l=0;
	int t;
	cin>>n>>t;
	vi a(n);
	for(auto &x:a) cin>>x;
	//sort(all(a));
	int i=0,j=n-1;
	//int p=i,q=j
	if(n!=1)
	{
		text;
		while(i!=n-1)
		{

			j=n-1;
			while(i<=j)
			{
				//debug(i);
			//debug(j);
			s=0;
				rep(p,i,j+1)
				{
					s+=a[p];
				}
				//debug(s);

				if(s<=t)
				{
					l=max(l,j+1-i);
					if(l==j+i+1){
					debug(i);
					debug(j);
				}

				}
				j--;
			}
			++i;
		}
}
else
{
	if(a[0]<=t)
	l=1;
}
	cout<<l<<endl;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define sq(a) (a)*(a)
#define debug(x) std::cerr<<#x<<"="<<x<<'\n'
#define text std::cerr<<"SacredCoupoid08\n"
#define endl '\n'
#define all(c) (c).begin(),(c).end()
#define U 1000000007
#define N 100005
#define sz(c) (int)c.size()
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pi;
#define cin std::cin
#define cout std::cout
#define vector std::vector
#define pb push_back
#define pv(x) for(auto y:x)    cerr<<y<<" ";    cerr<<'\n';
#define fr first
#define sc second
#define ppb pop_back
int main()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,s=0,l=0;
	int t;
	cin>>n>>t;
	vi a(n);
	for(auto &x:a) cin>>x;
	//sort(all(a));
	int i=0,j=n-1;
	//int p=i,q=j
	while(i!=n-2 && i!=1)
	{

		j=n-1;
		while(i<=j)
		{
			//debug(i);
		//debug(j);
		s=0;
			rep(p,i,j+1)
			{
				s+=a[p];
			}
			//debug(s);

			if(s<=t)
			{
				l=max(l,j+1-i);
				if(l==j+i+1){
				debug(i);
				debug(j);
			}

			}
			j--;
		}
		++i;
	}
	cout<<l<<endl;

	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
#include <math.h>
#include <cmath>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <iterator>
#include<bits/stdc++.h>
#define inn freopen("in.in","r",stdin)
#define outt freopen("out.out","w",stdout)
#include <random>
using namespace std;

int main()
{
    long long x,y,sum=0;
    cin>>x>>y;
    vector<long long> vec(x);
    for(long long i=0;i<vec.size();i++)
    {
        cin>>vec[i];
    }
    for(long long i=0,l=0;i<vec.size();i++)
    {
        l+=vec[i];
        if(l<=y)
           {++sum;}
        else
            l-=vec[i];
    }
    cout<<sum<<"\n";
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
#include <math.h>
#include <cmath>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <iterator>
#include<bits/stdc++.h>
#define inn freopen("in.in","r",stdin)
#define outt freopen("out.out","w",stdout)
#include <random>
using namespace std;

int main()
{
    long long x,y,sum=0;
    cin>>x>>y;
    vector<long long> vec(x);
    for(long long i=0;i<vec.size();i++)
    {
        cin>>vec[i];
    }
    sort(vec.begin(),vec.end());
    for(long long i=0,l=0;i<vec.size();i++)
    {
        l+=vec[i];
        if(l<=y)
           {sum++;}
    }
    cout<<sum<<"\n";
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
#include <math.h>
#include <cmath>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <iterator>
#include<bits/stdc++.h>
#define inn freopen("in.in","r",stdin)
#define outt freopen("out.out","w",stdout)
#include <random>
using namespace std;

int main()
{
    long long x,y,sum=0;
    cin>>x>>y;
    vector<long long> vec(x);
    for(long long i=0;i<vec.size();i++)
    {
        cin>>vec[i];
    }
    sort(vec.begin(),vec.end());
    for(long long i=0,l=0;i<vec.size();i++)
    {
        if(l<y)
           {++sum;}
        l+=vec[i];
    }
    cout<<sum<<"\n";
    return 0;
}


#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
int main()
{
    long long x,y,sum=0,counter=0,c=0;
    cin>>x>>y;
    vector<long long> vec(x);
    for(long long i=0;i<vec.size();i++)
    {
        cin>>vec[i];
    }
    for(long long i=0;i<vec.size();i++)
    {
        sum+=vec[i];
        if(sum<=y)
           {++counter;}
        else
        {
            sum-=vec[c];
            c++;
        }
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
#include <math.h>
#include <cmath>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <iterator>
#include<bits/stdc++.h>
#define inn freopen("in.in","r",stdin)
#define outt freopen("out.out","w",stdout)
#include <random>
using namespace std;

int main()
{
    long long x,y,sum=0;
    cin>>x>>y;
    vector<long long> vec(x);
    for(long long i=0;i<vec.size();i++)
    {
        cin>>vec[i];
    }
    for(long long i=0,l=0,j=0;i<vec.size();i++)
    {
        l+=vec[i];
        if(l<=y)
           {++sum;}
        else
        {l=0;sum=0;i=j;j+=1;}
    }
    cout<<sum<<"\n";
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
#include <math.h>
#include <cmath>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <iterator>
#include<bits/stdc++.h>
#define inn freopen("in.in","r",stdin)
#define outt freopen("out.out","w",stdout)
#include <random>
using namespace std;

int main()
{
    long long x,y,sum=0;
    cin>>x>>y;
    vector<long long> vec(x);
    vector<long long> temp;
    for(long long i=0;i<vec.size();i++)
    {
        cin>>vec[i];
    }
    for(long long i=0,l=0,j=0;i<vec.size();i++)
    {
        l+=vec[i];
        if(l<y)
           {++sum;}
        else if(l==y)
           {++sum;temp.push_back(sum);}
        else
        {l=0;sum=0;i=j;j+=1;}
    }
    sort(temp.begin(),temp.end());
    cout<<temp[temp.size()-1]<<"\n";
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
#include <math.h>
#include <cmath>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <iterator>
#include<bits/stdc++.h>
#define inn freopen("in.in","r",stdin)
#define outt freopen("out.out","w",stdout)
#include <random>
using namespace std;

int main()
{
    long long x,y,sum=0;
    cin>>x>>y;
    vector<long long> vec(x);
    for(long long i=0;i<vec.size();i++)
    {
        cin>>vec[i];
    }
    sort(vec.begin(),vec.end());
    for(long long i=0,l=0;i<vec.size();i++)
    {
        l+=vec[i];
        if(l<=y)
           {++sum;}
    }
    cout<<sum<<"\n";
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
#include <math.h>
#include <cmath>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <iterator>
#include<bits/stdc++.h>
#define inn freopen("in.in","r",stdin)
#define outt freopen("out.out","w",stdout)
#include <random>
using namespace std;

int main()
{
    long long x,y,sum=0;
    cin>>x>>y;
    vector<long long> vec(x);
    for(long long i=0;i<vec.size();i++)
    {
        cin>>vec[i];
    }
    for(long long i=0,l=0,j=0;i<vec.size();i++)
    {
        l+=vec[i];
        if(l<y)
           {++sum;}
        else if(l==y)
           {++sum;break;}
        else
        {l=0;sum=0;i=j;j+=1;}
    }
    cout<<sum<<"\n";
    return 0;
}


#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
int main()
{
    long long x,y,sum=0,counter=0,c=0;
    cin>>x>>y;
    vector<long long> vec(x);
    for(long long i=0;i<vec.size();i++)
    {
        cin>>vec[i];
    }
    for(long long i=0;i<vec.size();i++)
    {
        sum+=vec[i];
        if(sum<=y)
           {++counter;}
        else
        {
            sum-=vec[c];
            c++;
        }
    }
    cout<<counter<<"\n";
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
#include <math.h>
#include <cmath>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <iterator>
#include<bits/stdc++.h>
#define inn freopen("in.in","r",stdin)
#define outt freopen("out.out","w",stdout)
#include <random>
using namespace std;

int main()
{
    long long x,y,sum=0;
    cin>>x>>y;
    vector<long long> vec(x);
    for(long long i=0;i<vec.size();i++)
    {
        cin>>vec[i];
    }
    sort(vec.begin(),vec.end());
    for(long long i=0,l=0;i<vec.size();i++)
    {
        if((l+vec[i])<y)
           {++sum;}
        l+=vec[i];
    }
    cout<<sum<<"\n";
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
#include <math.h>
#include <cmath>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <iterator>
#include<bits/stdc++.h>
#define inn freopen("in.in","r",stdin)
#define outt freopen("out.out","w",stdout)
#include <random>
using namespace std;

int main()
{
    long long x,y,sum=0;
    cin>>x>>y;
    vector<long long> vec(x);
    for(long long i=0;i<vec.size();i++)
    {
        cin>>vec[i];
    }
    for(long long i=0,l=0;i<vec.size();i++)
    {
        l+=vec[i];
        if(l<=y)
           {++sum;}
        else
            l=vec[i];
    }
    cout<<sum<<"\n";
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
#include <math.h>
#include <cmath>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <iterator>
#include<bits/stdc++.h>
#define inn freopen("in.in","r",stdin)
#define outt freopen("out.out","w",stdout)
#include <random>
using namespace std;

int main()
{
    long long x,y,sum=0;
    cin>>x>>y;
    vector<long long> vec(x);
    for(long long i=0;i<vec.size();i++)
    {
        cin>>vec[i];
    }
    sort(vec.begin(),vec.end());
    for(long long i=0,l=0;i<vec.size();i++)
    {
        if(l<=y)
           {++sum;}
        l+=vec[i];
    }
    cout<<sum<<"\n";
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
#include <math.h>
#include <cmath>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <iterator>
#include<bits/stdc++.h>
#define inn freopen("in.in","r",stdin)
#define outt freopen("out.out","w",stdout)
#include <random>
using namespace std;

int main()
{
    long long x,y,sum=0;
    cin>>x>>y;
    vector<long long> vec(x);
    for(long long i=0;i<vec.size();i++)
    {
        cin>>vec[i];
    }
    sort(vec.begin(),vec.end());
    for(long long i=0;i<vec.size();i++)
    {
        if((sum+vec[i])<y)
           {++sum;}
    }
    cout<<sum<<"\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, t;
    cin>>n>>t;
    int ara[n];
    for(int i = 0; i < n; i++) cin>>ara[i];
    for(int i = n - 2; i >= 0; i--)
        ara[i] = ara[i] + ara[i+1];
    for(int i = 0; i < n; i++)
    {
        if(ara[i] <= t)
        {
            cout<<n - i<<endl;
            return 0;
        }
    }
    cout<<"0"<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int two_pointer(int ara[], int n, int t)
{
    int ans = 0, l, r;
    for(int i = 1; i <= n; i++)
    {
        l = i, r = n;
        while(l <= r)
        {
            // if((i == 4)) cout<<l<<" "<<r<<endl;
            if(ara[r] - ara[i-1] <= t)
            {
                ans = max(ans, (r - i) + 1);
                break;
            }
            if(ara[r] - ara[i-1] > t) r--;
            if(ara[l] - ara[i-1] > t)
            {
                //cout<<i<<" "<<l<<endl;
                ans = max(ans, l - i);
                break;
            }
            else l++;
        }
        ans = max(ans, l - i);
    }
    return ans;
}

int main()
{
    int n, t;
    cin>>n>>t;
    int ara[n+1] = {0};
    for(int i = 1; i <= n; i++) cin>>ara[i];
    for(int i = 1; i <= n; i++) ara[i] = ara[i] + ara[i-1];
    cout<<two_pointer(ara, n, t)<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int two_pointer(int ara[], int n, int t)
{
    int l = 1, r = 1, ans = 0;
    while((l <= r) && (r <= n))
    {
        while((ara[r] - ara[l-1]) <= t && r <= n) r++;
        //r--;
        ans = max(ans, r - l);
        l++;
        if(l > r) r = l;
    }
    return ans;
}

int main()
{
    int n, t;
    cin>>n>>t;
    int ara[n+1] = {0};
    for(int i = 1; i <= n; i++) cin>>ara[i];
    for(int i = 1; i <= n; i++) ara[i] = ara[i] + ara[i-1];
    cout<<two_pointer(ara, n, t)<<endl;
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fast() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
#define ll long long
#define ull unsigned long long
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define oset tree < int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update >

/* Helper Functions */
int nCk(ll n, ll k){
    ll res = 1;
    for (ll i = 0; i < k; ++i){
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

int power(ll x, unsigned int y){
    ll res = 1;
    while (y > 0){
      if (y & 1) res = res*x;
      y = y>>1;
      x = x*x;
    }
    return res;
}

ll power(ll base, ll exp, ll N)
{
    ll t = 1LL;
    while (exp > 0)  {
        if (exp & 1) t = (t * base) % N;
        base = (base * base) % N;
    }
    return t % N;
}

int main()
{
    fast();
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    if(n*25 < k){
      cout<<"-1\n";
      return 0;
    }
    for(int i = 0; i < n; i++){
      int mx_lim;
      char replacer;
      if((s[i]-'a') >= ('z' - s[i])){
        mx_lim = s[i]-'a';
        replacer = 'a';
      }
      else{
        mx_lim = 'z' - s[i];
        replacer = 'z';
      }
      //cout<<"MaX-Diff: "<<mx_lim<<" & Replacer: "<<replacer<<'\n';
      if(k >= mx_lim){
        k -= mx_lim;
        s[i] = replacer;
      }
      else{
        if(char(s[i] - k) >= 'a') s[i] = char(s[i]-k);
        else if(char(s[i] + k) <= 'z') s[i] = char(s[i]+k);
        k = 0;
        break;
      }
    }

    if(k != 0) cout<<-1<<'\n';
    else cout<<s<<'\n';
    return 0;
  }


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fast() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
#define ll long long
#define ull unsigned long long
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define oset tree < int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update >

/* Helper Functions */
int nCk(ll n, ll k){
    ll res = 1;
    for (ll i = 0; i < k; ++i){
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

int power(ll x, unsigned int y){
    ll res = 1;
    while (y > 0){
      if (y & 1) res = res*x;
      y = y>>1;
      x = x*x;
    }
    return res;
}

ll power(ll base, ll exp, ll N)
{
    ll t = 1LL;
    while (exp > 0)  {
        if (exp & 1) t = (t * base) % N;
        base = (base * base) % N;
    }
    return t % N;
}

int main()
{
    fast();
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    if(n*25 < k){
      cout<<"-1\n";
      return 0;
    }
    for(int i = 0; i < n; i++){
      int mx_lim;
      char replacer;
      if((s[i]-'a') >= ('z' - s[i])){
        mx_lim = s[i]-'a';
        replacer = 'a';
      }
      else{
        mx_lim = 'z' - s[i];
        replacer = 'z';
      }
      //cout<<"MaX-Diff: "<<mx_lim<<" & Replacer: "<<replacer<<'\n';
      if(k > mx_lim){
        k-=mx_lim;
        s[i] = replacer;
      }
      else{
        if(char(s[i] + k) <= 'z') s[i] = char(s[i]+k);
        else s[i] = char(s[i]-k);
        k = 0;
        break;
      }
    }

    if(k != 0) cout<<-1<<'\n';
    else cout<<s<<'\n';
    return 0;
  }


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fast() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
#define ll long long
#define ull unsigned long long
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define oset tree < int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update >

/* Helper Functions */
int nCk(ll n, ll k){
    ll res = 1;
    for (ll i = 0; i < k; ++i){
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

int power(ll x, unsigned int y){
    ll res = 1;
    while (y > 0){
      if (y & 1) res = res*x;
      y = y>>1;
      x = x*x;
    }
    return res;
}

ll power(ll base, ll exp, ll N)
{
    ll t = 1LL;
    while (exp > 0)  {
        if (exp & 1) t = (t * base) % N;
        base = (base * base) % N;
    }
    return t % N;
}

int main()
{
    fast();
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    if(n*25 < k){
      cout<<"-1\n";
      return 0;
    }
    for(int i = 0; i < n; i++){
      int mx_lim;
      char replacer;
      if((s[i]-'a') >= (s[i]-'a'+23)){
        mx_lim = s[i]-'a';
        replacer = 'a';
      }
      else{
        mx_lim = s[i]-'a'+23;
        replacer = 'z';
      }
      //cout<<"MaX-Diff: "<<mx_lim<<" & Replacer: "<<replacer<<'\n';
      if(k > mx_lim){
        k-=mx_lim;
        s[i] = replacer;
      }
      else{
        if(char(s[i] + k) <= 'z') s[i] = char(s[i]+k);
        else s[i] = char(s[i]-k);
        k = 0;
        break;
      }
    }

    if(k != 0) cout<<-1<<'\n';
    else cout<<s<<'\n';
    return 0;
  }


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fast() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
#define ll long long
#define ull unsigned long long
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define oset tree < int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update >

/* Helper Functions */
int nCk(ll n, ll k){
    ll res = 1;
    for (ll i = 0; i < k; ++i){
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

int power(ll x, unsigned int y){
    ll res = 1;
    while (y > 0){
      if (y & 1) res = res*x;
      y = y>>1;
      x = x*x;
    }
    return res;
}

ll power(ll base, ll exp, ll N)
{
    ll t = 1LL;
    while (exp > 0)  {
        if (exp & 1) t = (t * base) % N;
        base = (base * base) % N;
    }
    return t % N;
}

int main()
{
    fast();
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    if(n*25 < k){
      cout<<"-1\n";
      return 0;
    }
    for(int i = 0; i < n; i++){
      int mx_lim;
      char replacer;
      if((s[i]-'a') >= ('z' - s[i])){
        mx_lim = s[i]-'a';
        replacer = 'a';
      }
      else{
        mx_lim = 'z' - s[i];
        replacer = 'z';
      }
      //cout<<"MaX-Diff: "<<mx_lim<<" & Replacer: "<<replacer<<'\n';
      if(k >= mx_lim){
        k -= mx_lim;
        s[i] = replacer;
      }
      else{
        if(char(s[i] + k) <= 'z') s[i] = char(s[i]+k);
        else if(char(s[i] - k) >= 'a') s[i] = char(s[i]-k);
        k = 0;
        break;
      }
    }

    if(k != 0) cout<<-1<<'\n';
    else cout<<s<<'\n';
    return 0;
  }


#include <iostream>
#include<string>
using namespace std;
string s,x;
int n,m;
int main()
{
    cin>>n>>m;
    cin>>s;
    if (n*25<m) {cout<<-1;return 0;}
    int q=m/n,r=m%n;
    for(int i=0;i<(int)s.size();i++)
    {
        x=x+char((int(s[i])-97+q+int(r!=0))%26+97);
        if (r>0) r--;
    }
    cout<<x;
    return 0;
}


#include <iostream>
#include<string>
using namespace std;
string s,x;
int n,m;
int main()
{
    cin>>n>>m;
    cin>>s;
    if (n*25<m) {cout<<-1;return 0;}
    int q=m/n,r=m%n;
    for(int i=0;i<(int)s.size();i++)
    {
        x=x+char((int(s[i])-97+q+int(r!=0))%26+97);
        r--;
    }
    cout<<x;
    return 0;
}


#include <iostream>
#include<string>
using namespace std;
string s,x;
int n,m;
int main()
{

    cin>>n>>m;
    cin>>s;
    if (n*25<m) {cout<<-1;return 0;}
    for(int i=0;i<(int)s.size();i++)
    {
        int dist;
        if ('z'-s[i]>s[i]-'a')
        {
            dist=min('z'-s[i],m);
            x=x+char(int(s[i])+dist);
        }
        else
        {
            dist=min(s[i]-'a',m);
            x=x+char(int(s[i])-dist);
        }
        m-=dist;
        if (m<0) {cout<<-1;return 0;}
    }
    if (m>0){cout<<-1;return 0;}
    cout<<x;
    return 0;
}


#include <iostream>
#include<string>
using namespace std;
string s,x;
int n,m;
int main()
{

    cin>>n>>m;
    cin>>s;
    if (n*25<m) {cout<<-1;return 0;}
    for(int i=0;i<(int)s.size();i++)
    {
        int dist;
        if ('z'-s[i]>s[i]-'a')
        {
            dist=min('z'-s[i],m);
            x=x+char(int(s[i])+dist);
        }
        else
        {
            dist=min(s[i]-'a',m);
            x=x+char(int(s[i])-dist);
        }
        m-=dist;
        if (m<0) {cout<<-1;return 0;}
    }
    cout<<x;
    return 0;
}