#include<bits/stdc++.h>
using namespace std;
int main()
{

	long int n,m;
	cin>>n>>m;
	long int con=0,cont=0;

	while(n--)
	{
		int y;
		cin>>y;

		if(con+y>m)
		{
			cont++;
			con=y;

		}
		else
		{
			con+=y;

		}

	}
	if(con>0)
	cont++;
	cout<<cont;

}

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

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

    int a[n];

    for(int i=0;i<n;i++)
    cin>>a[i];

    int bus=1,temp=0;

    for(int i=0;i<n;i++)
    {
        if(temp+a[i]<=m)
        temp+=a[i];

        else
        {
            bus++;
            temp=a[i];
        }

    }

    cout<<bus;
}

#include <iostream>
using namespace std;
int main()
{
    int n,m,A,sum=0,S=0,Count_buses=0;
    cin>>n>>m;
    for(int i=1; i<=n; i++){
        cin>>A;
        if(A<m)
            sum+=A;
        else
        {
            Count_buses+=1;
            if(sum>0)
            {
                Count_buses+=1;
                sum=0;
            }
        }
        if(sum==m)
        {
            Count_buses+=1;
            sum=0;
        }
        else if(sum>m)
        {
            Count_buses+=1;
            sum=A;
        }
        if(i==n)
        {
            if(sum>0)
                Count_buses+=1;
        }
    }
cout<<(Count_buses);
}

#include <map>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std ;

#define sz size()
#define eps (1e-9)
#define inf (1 << 28)
#define pb push_back
#define del( a , b ) memset( a , b , sizeof ( a ) )

int main ()
{
    int n , m , i ;
    scanf("%d %d",&n,&m);
    int ans = 1, left = m ;
    for( i=0 ; i<n ; i++ )
    {
        int a ;
        scanf ("%d",&a);
        if ( left >= a )
            left -= a ;
        else
        {
            ans ++ ;
            left = m - a ;
        }
    }
    printf("%d\n", ans);
    return 0;
}

#include<iostream>

using namespace std;

int main()
{
	int n, m, sum = 0, ans = 0, x;
	int *a = NULL;
	cin >> n >> m;
	a = new int[n];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
	{
		while (sum + a[i] <= m && i<n)
		{
			sum += a[i];
			i++;
		}
		i -- ;
		sum = 0;
		ans++;
	}
	cout << ans;
	//system("pause");
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m, groups[1001];
main() {
    cin>>n>>m;
    for (ll i = 0; i < n; i++) {
        cin>>groups[i];
    }
    ll bus = m, index, count = 1;
    while (index < n) {
        if(bus - groups[index] >= 0) {
            bus -= groups[index];
            index++;
        }
        else{
            bus = m;
            count++;
        }

    }
    cout<<count;
}

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, m,count=0,a;
    cin >> n >> m;
   if (n==1){cout<<1;
       return 0;}
   vector<int>v;
    for (int i = 0; i <n ; ++i) {
       cin>>a;
        v.push_back(a);
    }
    while(!v.empty()){
        int sum=v[0];
        a=0;
        for (int i = 1; i <v.size() ; ++i) {
            if (sum+v[i]<=m){
                sum+=v[i];
                a++;
            } else
            {
                break;
            }
        }
        a++;
        v.erase(v.begin(),v.begin()+a);
        count++;
    }
    cout<<count;

}

#include<bits/stdc++.h>
using namespace std;
int n,m,s,ans=1,sum;
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>s;
        if(s+sum>m)
        {
            sum=0;
            ans++;
        }
        sum+=s;
    }
    cout<<ans;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int s,n,m,t,cur,ans,in;

int main(){
    vector <int> a;
    cin >> n >> m;
    for (int i=0;i<n;i++){
        cin >> t;
        a.push_back(t);
    }
    while(in<n){
        if (a[in]+cur<m)
            {
                cur+=a[in];
                in++;
                continue;
            }
        if (a[in]+cur==m){
            cur=0;
            ans++;
            in++;
            continue;
        }
        if (a[in]+cur>m){
            cur=0;
            ans++;
            continue;
        }
    }
    cout << ans+min(cur,1);
}

#include<bits/stdc++.h>
using namespace std;
int main()
{

    int n,m,sum=0,cnt=0;
    cin>>n>>m;
    int arr[n+5];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }

    for(int i=0;i<n;i++)
    {
        sum = sum+arr[i];
        if(sum<m)
        {

        }
        else if(sum>m)
        {
            cnt++;
            sum=arr[i];
        }
        else
        {
            cnt++;
            sum=0;
        }

    }
    if(sum>0)
    {
        cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}

#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

using namespace std;
typedef long long Long;

int main() {
    ios_base::sync_with_stdio(0);
#ifdef IDE
    freopen("C:\\input.txt", "r", stdin);
#endif
    int n, m;
    cin >> n >> m;
    int sum = 0;
    int res = 0;
    vector<int> arr(n);
    for (int &w : arr) cin >> w;
    for (int i = 0; i < n; ++i) {
        if (sum + arr[i] <= m) {
            sum += arr[i];
        } else {
            sum = arr[i];
            ++res;
        }
    }
    if (sum) ++res;
    cout << res << '\n';

    return 0;
}

#include <cstdio>
#include <iostream>
#include <string>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <iomanip>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define mt(a,b,c) mp(a,mp(b,c))
#define mf(a,b,c,d) mp(mp(a,b),mp(c,d))
#define PI 3.14159265358979323846264
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dy[] = { 0, 0, 1, -1 };    //동, 서, 남, 북
int dx[] = { 1, -1, 0, 0 };
int N, M;
int sum;
int main() {
	int ans = 0;
	scanf("%d%d", &N, &M);
	for (int n = 0; n < N; n++) {
		int v;
		scanf("%d", &v);
		if (sum + v > M){
			sum = v;
			ans++;
		}
		else{
			sum += v;
		}
		if (sum == M) ans++, sum = 0;
	}
	if (sum) ans++;
	printf("%d\n", ans);
	return 0;
}

#include <vector>
#include <string>
#include <cstring>
#include <iostream>
#include <stdlib.h>
#include <algorithm>

using namespace std;

int main() {
	int N, M;

	cin >> N >> M;

	vector<int> A;
	A.resize(N);

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

	int res = 0;
	size_t i = 0;
	while (i < N) {
		res++;
		int t = 0;
		do {
			t+=A[i];
			i++;
		} while (i < N && A[i] + t <= M);
	}

	cout << res << endl;

	return 0;
}

#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <limits>
//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#include <utility>
#include <list>
#include <cstdio>
#include<forward_list>
#include<algorithm>
#include<string>
#define Omar_Hafez ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.1415926536
#define ll long long
#define ull unsigned long long
#define lli long long int
using namespace std;
int main()
{
    Omar_Hafez
        int n, m; cin >> n >> m;
    int x;
    int count = 0, sum = 0;
    bool check = false;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        if (count + x <= m)
        {
            count +=x ;
            check = true;
        }
        else
        {
            sum++;
            count = x;
        }

    }
    if(check==true)
    sum++;
    cout << sum << "\n";
        return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int a, n, m;
    int b, i, k;

    cin >> n >> m;

    if (n == 1)
        k = 1;
    else
    {
        a = 0;
        k = 0;
        for (i = 0; i < n; i++)
        {
            cin >> b;
            a = a + b;
            if (a >= m)
            {
                k++;
                if (a > m)
                {
                    if (i == n - 1)
                    {
                        k++;
                        break;
                    }
                    a = b;
                    continue;
                }
                if (a == m)
                {
                    a = 0;
                    continue;
                }

            }
            else
                if (i == n - 1) k++;
        }
    }

    cout << k;

    return 0;
}

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

int main()
{   int n,m;
int a;
int x=0;
int c=0;
cin>>n>>m;

for(int i=0;i<n;i++)
{cin>>a;
if(a+x<=m)
{x+=a;
}
else
{c++;
x=a;
}
}
cout<<c+1<<endl;
return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	long int n,m;
	cin>>n>>m;
	long int arr[n];
	for(long int i=0;i<n;i++)
		cin>>arr[i];
	long int bn=0;
	long int i=0;
	while(i<n)
	{
		bn++;
		long int sa=m;
		while(sa>0 && i<n)
			if(sa-arr[i]>=0)
			{
				sa=sa-arr[i];
				i++;
			}
			else
				sa=0;
	}
	cout<<bn<<endl;
	return 0;
}

#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main ()
{
         int a,b,c,c1,c2,d=0;
cin>>a>>b;
cin>>c1;
c2=c1;
for (int i=0;i<a-1;i++)
{
         cin>>c;
         if (c2+c>b) {d++;c2=c;}
         else {c2+=c;}
         c1=c;
    }
    cout<<d+1<<endl;
         return 0;
         }

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int a[110];
//int p[55];

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int i;
    int sum=0,ans=1;
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(i=0;i<n;i++)
    {
        if(sum+a[i]>m)
        {
            ans++;
            sum=a[i];
        }
        else
            sum+=a[i];
    }
    printf("%d\n",ans);
    return 0;
}

#include <iostream>
/*
  Link: http://codeforces.com/problemset/problem/435/A
*/

#include <cstdio>

#include <algorithm>
#include <stack>

using namespace std;

int n, m, groups[100 + 10];

int main() {

    scanf("%d %d", &n, &m);

    for (int i = 0; i < n; i++) {
        scanf("%d", &groups[i]);
    }

    int bus = m, index, count = 1;

    while (index < n) {

        if (bus - groups[index] >= 0) {
            bus -= groups[index];
            index++;
        } else {
            bus = m;
            count++;
        }

    }

    cout << count;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int a[100001];
int main()
{
    int n,m,a,cnt=0,ans=0;cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>a;
        if(cnt+a>m){
        ans++; cnt=0; }
        cnt+=a;
    }
    cout<<ans+1;
    return 0;
}

#include <iostream>

using namespace std;

int main()
{

     int n; int m;  cin >> n >>m;
     int counter = 0;
     bool assigne = false;

    int a0 ; cin >> a0;
    //cout <<"a0  "<<a0<<endl<<"------------------"<<endl;
    if (a0==m){counter++ ; assigne=true;
    //cout <<"a0 equal m "<<assigne<<endl<<"------------------"<<endl;
    }
    if (n==1) {cout<<counter+1; return 0;}

    bool p = true;

     for (int i = 0 ; i <n-1 ; i++)
    {
        int next;
        cin >> next;
     if (assigne == true){ a0=next ; p=false; assigne=false;
      if (a0 == m){counter++ ; assigne=true;}
     //cout <<"assigned "<<a0 << "   " <<i<<endl<<"------------------"<<endl;
     }

      if ((a0+next ==m)  &&(p==true)) {p=false; counter++ ; assigne=true;                            /*cout <<"done =  "<<counter<<"  "<<assigne <<endl<<"------------------"<<endl;*/}
      if ((a0+next > m)  &&(p==true)) {p=false;counter++ ; a0=next; if(i==n-2){counter++;}           /*cout <<"high  "<<a0<<endl<<"------------------"<<endl;*/}
      if ((a0+next < m)  &&(p==true)) {p=false;a0= a0+next;    if(i==n-2){counter++;}                                       /*cout <<"no  "<<a0<<endl<<"------------------"<<endl;*/}

      p=true;
    }

   cout <<counter <<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,sum=0,cnt=0;
    cin>>n>>m;
    int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n;i++)
    {
        if(sum+a[i]<=m)
        {
            sum=sum+a[i];
        }
        else
        {
            sum=a[i];
            cnt++;
        }
    }
    cout<<cnt+1<<endl;
}

#include<iostream>

using namespace std;

int main()

{
    int a[101],n,k=0,m,ans=0,i;
    cin>>n>>m;

    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(k+a[i]>m)ans++,k=a[i];
        else k+=a[i];

    }
    if(k)ans++;
    cout<<ans;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define Jewel ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()
{
    Jewel;
    int n, m , a, sum=0, bus=1;
    cin>>n>>m;
    while(n--)
    {
        cin>>a;
        if(sum+a <= m)
        {
            sum += a;
        }
        else
        {
            bus++;
            sum = a;
        }

    }
    cout<<bus<<endl;
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll ;
typedef pair <int, int> pii;
typedef vector<int> vi;

int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	int n, m, k = 0;
	cin >> n >> m;
	vi a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	k++;
	int s = m - a[0];
	for (int i = 1; i < n; i++)
	{
		if (a[i] > s)
		{
			k++;
			s = m - a[i];
		}
		else
			s -= a[i];
	}
	cout << k;

	return 0;
}

#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define inf 200000000000000000LL
#define Min(a,b) (a<b?a:b)
#define Max(a,b) (a>b?a:b)
#define For(i,s,n) for (ll i=s;i<=n;i++)
#define FOR(i,s,n) for (int i=s;i<n;i++)
#define Ford(i,s,n) for (int i=s;i>=n;i--)
#pragma comment(linker, "/STACK:16777216")

#define MD 1000000007
#define PI 3.1415926535897932384626433832795

typedef long long ll;

using namespace std;

int main(){
	//freopen("i.txt", "r", stdin); freopen("o.txt", "w", stdout);
	int n, m;
	scanf("%d%d", &n, &m);
	int Ans = 0, x, Prev = m;
	For(i, 1, n){
		scanf("%d", &x);
		if (Prev >= x) Prev -= x; else Prev = m - x, Ans++;
	}
	printf("%d\n", Ans + 1);
}

#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=a; i<b; i++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define el "\n"
using namespace std;
typedef long long ll;
vector< pair<int,int> >v;
vector<ll> a;
vector<ll> b;
int main()
{//freopen("a.txt","r",stdin);
ll n,x,m,s=0,k=0,bus=0,i=0; cin>>n>>m;
REP(j,0,n) {cin>>x; a.PB(x);}
   while (i<n)
   {
       while (s<=m) {s+=a[i]; i++;}
       if (s>m) i--;
       s=0;
       bus++;
   }
   cout<<bus<<el;

    return 0;

}

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int n, m, res, p;

int main(){
	scanf("%d%d", &n, &m);
	p=0;
	res=1;
	for(int a=0;a<n;a++){
		int v;
		scanf("%d", &v);
		if(p+v<=m){
			p+=v;
		}
		else{
			res++;
			p=v;
		}
	}
	printf("%d\n", res);
	return 0;
}

/*
4 3
2 3 2 1

3 4
1 2 1

6 4
1 2 1 0 4 1

*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#define PI 3.14159265358979323846
#define PO << " " <<
#define P " "
#define ABS(x) (((x) > 0) ? (x) : (-(x)))
#define RND(x) ((int)( (x) + 0.5 ))
#define MAX(x, y) (( (x) > (y) ) ? (x) : (y))
#define MIN(x, y) (( (x) < (y) ) ? (x) : (y))
#define LOOP(i, ending) for (int i = 0; i < ending; i++)
#define HLP int VS2012WAIT; cin >> VS2012WAIT;
using namespace std;
int main()
{
    int N, m;
    cin >> N >> m;
    int * a = new int [N];
    int avt = 0;
    int pred = 0;
    LOOP(i, N)
    {
        cin >> a[i];
        if (a[i] == m)
        {
            if (pred)
                avt++;
            avt++;
            pred = 0;
        }
        else
            if (pred + a[i] > m)
            {
                avt++;
                pred = a[i];
            }
            else
                pred += a[i];
    }
    if (pred) avt++;
    cout << avt;
    HLP
    delete[] a;
    return 0;
}

#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <string>
#include <cstring>
#include <cassert>
#include <cmath>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int answer = 1; answer <= n; answer++) {
		int tmp = m;
		for (int j = 0; j < n; j++)
			if (tmp >= a[j]) {
				tmp -= a[j];
				a[j] = 0;
			}
			else
				break;
		int x = 0;
		for (int e : a)
			x += e;
		if (x == 0) {
			cout << answer << endl;
			break;
		}
	}
	return 0;
}

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
   int m,n,y=0,z=0;
   cin>>m>>n;
   int x[m];
   for(int i=0;i<m;i++)
   {
       cin>>x[i];

   }
   for(int i=0;i<m;i++)
   {

        y+=x[i];
        if(y==n)
        {
            z++;
            y=0;
        }
        else
        if(y>n)
        {
            z++;
            y=x[i];
        }
        if(i==(m-1)&&y!=0)
        {
            z++;
        }
   }
   cout<<z<<endl;
     return 0;
}

//In the Name of God
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <cctype>
using namespace std;
//#include <conio.h>
int a[1000000];
int b[1000000];
int c[1000000];
int main()
{
	int n,d=0,k=0,f=0;
	cin>>n>>d;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	k=a[1];
	for(int i=2;i<=n;i++){
		if(d>=a[i]+k){
			k+=a[i];
		}
		else{
			f++;
			k=a[i];
		}
	}
	if(k!=0)
	cout<<f+1;
	else
	cout<<f;
}

/*
Author: richard
Contact: zhangruichang112@gmail.com
*/
#include<set>
#include<map>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<ctime>
#include<cstdio>
#include<string>
#include<vector>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<fstream>
#include<iostream>
#include<algorithm>
#include <unordered_set>
#include <unordered_map>
using namespace std;
const int maxn = 1e6 + 10;
typedef long long LL;
typedef unsigned long long ULL;
//int, -2^31~2^31-1    -2.1*10^9~2.1*10^9 (-2147483648-2147483647)
//unsigned int, 0~2^32-1  0~4.2*10^9
//long long  -2^63~2^63-1 -9*10^18~9*10^18
//unsigned long long 0~2^64-1  0~1.8*10^19
typedef pair<int, int> pii;
#define f first
#define s second
int getint(){
	int t = 0, flag = 1; char c = getchar();
	while (c<'0' || c>'9' || c == '-')
	{
		if (c == '-')
			flag = -1;
		c = getchar();
	}
	while (c >= '0'&&c <= '9')
		t = t * 10 + c - '0', c = getchar();
	return t*flag;
}
int GCD(int m, int n)
{
    if(!m) return n;
    return GCD(n%m, m);//yushu and chushu
}
int a[maxn];
int main()
{
/*
#ifndef ONLINE_JUDGE
    freopen ("in.txt" , "r" , stdin);
    freopen ("out.txt" , "w" , stdout);
#endif
*/
    int n, m;
    while(cin>>n>>m)
    {
        int ans=0;
        for(int i=0;i<n;i++) cin>>a[i];
        for(int i=0;i<n;)
        {
            int j, sum=a[i];;;
            for(j=i+1; j<n && sum+a[j]<=m ; j++) sum+=a[j];
            ans++;
            i=j;
        }
        cout<<ans<<endl;
    }
	return 0;
}

#include <bits/stdc++.h>
#define int         long long
#define ll			long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define nl          '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

signed main(){
	int n,m;
	cin >> n >> m;
	int a[n];
	rep(i,0,n){
		cin >> a[i];
	}
	int c=0;
	int temp=m;
	// cout << "TEP " << temp <<nl;
	rep(i,0,n){
		while(a[i]<=temp and i<n){
			temp-=a[i];
			// cout << temp <<' ' << a[i] <<nl;
			i++;

		}
		i--;
		temp=m; c++;
	}
	cout << c <<nl;
}

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <numeric>

using namespace std;

typedef long long ll;
typedef long double ld;

template<typename X> inline X sqr(const X& a) { return a * a; }

#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define file_name(a) (freopen(((string)(a) + ".in").c_str(),"r",stdin), freopen(((string)(a) + ".out").c_str(),"w",stdout))
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int nxt() {
	int x;
	cin >> x;
	return x;
}

int main() {
	int n = nxt(), m = nxt();
	vector <int> a(n);
	generate(all(a), nxt);
	int cnt = 0, ans = 0;
	forn(i, n) {
		if (a[i] + cnt <= m) {
			cnt += a[i];
		}
		else {
			ans++;
			cnt = a[i];
		}
	}
	if (cnt) {
		ans++;
	}
	cout << ans << '\n';
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
int a[2000],n,m,ans,s;
int main() {
    cin>>n>>m;
    for(int i=1;i<=n;i++) {
		cin>>a[i];
		if (a[i]+s<=m)
			s+=a[i];
		else
			ans++,s=a[i];
		if(a[i]==m)
			ans++,s=0;
	}
    if(s)
		ans++;
    cout<<ans<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,m,ans=1,now,x;
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		now+=x;
		if (now>m)
		{
			ans++;
			now=x;
		}
	}
	printf("%d",ans);
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

int main()
{
	int n, m, t, ans = 1, curr = 0, rem;
	vector<int> vec;

	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> t;
		if(t+curr > m){
			ans++;
			curr = 0;
		}
		curr += t;
	}

	cout << ans << endl;

	return 0;
}

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

int main()
{
    int n,m;
    cin>>n>>m;
    int arr[n+2];
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    int sum=0,c=0;
    if(n==1)
        cout<<"1"<<endl;
    else
    {
        for(int i=0; i<n; i++)
        {
            sum+=arr[i];
            if(sum==m)
            {
                c++;
                sum=0;
            }
            else if(sum>m)
            {
                sum=0;
                i--;
                c++;
            }

        }
        if(sum<m && sum != 0)
            c++;
        cout<<c<<endl;
    }
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    int n,m,trash,sum=0,ans=1;
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        cin>>trash;
        if(sum+trash<=m)
            sum+=trash;
        else
        {
            sum=trash;
            ans++;
        }
    }
    cout<<ans;
}

#include <iostream>

using namespace std;

int main()
{
    int n;
    int m;
    int a[100];
    int C = 0;
    int B = 1;
    int x;
    int S = 0;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        S = S + a[i];
    }
    x = m;
    C = 0;
    if (S > m)
    {
        for (int i = 0; i < n; i++)
        {
            if (a[i] <= x)
            {
                C = C + a[i];
                x = m - C;
            }
            else
            {
                B = B + 1;
                C = 0;
                x = m;
                i--;
            }

        }
    }
    else
        B = 1;
    cout << B << endl;
        return 0;
}

#include <bits/stdc++.h>
using namespace std;
int parts[105],n,m,car,ans=0;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	cin>>parts[i];
	for(int i=1;i<=n;i++)
	{
		if(car+parts[i]>m)
		{
			ans++;
			car=parts[i];
		}
		else
		car+=parts[i];
	}
	if(car!=0)
	ans++;
	cout<<ans;
	return 0;
}

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long int lld;
typedef long double Lf;
typedef unsigned long long int llu;

#define sz(a)                        int((a).size())
#define pb                           push_back
#define mp                           make_pair
#define F                            first
#define S                            second
#define present(c,x)                 ((c).find(x) != (c).end())
#define cpresent(c,x)                (find(all(c),x) != (c).end())
#define si(n)                        inp(n)
#define sl(n)                        scanf("%lld",&n)
#define sf(n)                        scanf("%f",&n)
#define sd(n)                        scanf("%lf",&n)
#define ss(n)                        scanf("%s",n)
#define sii(n,m)		     inp(n);inp(m)
#define siii(n,m,r)		     inp(n);inp(m);inp(r)

#define abs(x)                       ((x)<0?-(x):(x))
#define fill(a,v)                    memset((a),(v),sizeof (a))
#define INF                          INT_MAX
#define LINF                         (long long)1e18
#define EPS                          1e-9
#define MODBY 1000000007

/*int p[1000011];
VI prms;
void sieve(int n)
{int i,j;prms.pb(2);;fi(i,3,n){if(!i%2||!p[i])continue;prms.pb(i);for(j=2*i;j<n;j+=i)p[j]=1;}}*/

inline void inp( int &n )
{
n=0;
int ch=getchar();int sign=1;
while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getchar();}

while( ch >= '0' && ch <= '9' )
n = (n<<3)+(n<<1) + ch-'0', ch=getchar();
n=n*sign;
}

int main()
{
	int bus = 1,n,m,a[110];
	int gp = 0;
	sii(n,m);
	for(int i=0;i<n;i++) si(a[i]);
	for(int i=0;i<n;i++)
	{
		if (gp + a[i] <= m)
			gp += a[i];
		else
		{
			bus++;
			gp = a[i];
		}
	}
	cout << bus << endl;
}

#include<iostream>
#include<cmath>
#include<string>
#include<cctype>
#include<vector>
#include<numeric>
#include<algorithm>
using namespace std;
/**
vector<int>ar(3);
for(auto&e:ar){
    scanf("%d",&e);
        }
sort(ar.begin(),ar.end())
int sum=accumulate(ar.begin(),ar.end(),0);
**/

int main(){
        double pai=3.141592653589;
    int n,m,chk=0,ans=1;
    scanf("%d %d",&n,&m);
    vector<int>a(n);
    for(auto&e:a){
        scanf("%d",&e);
    }
    while(n>0){
        if(chk+a[0]<=m){
            chk+=a[0];
            a.erase(a.begin());
            --n;
        }else{
            ++ans;
            chk=0;
        }
    }
    printf("%d\n",ans);
    return 0;
}

#include <iostream>

using namespace std;

int main()
{int n,m,s=0,ans=1,x=0;
int a[100001]={};
cin>>n>>m;
for (int i=0; i<n; i++)
{cin>>a[i];
if (x+a[i]<=m) x=x+a[i]; else {x=a[i]; ans++;}
}
cout<<ans;
    return 0;
}

#include <iostream>
using namespace std;
int a[110];
int main(){

    int n, m;
    int summ=0, cnt=0;
    cin>>n>>m;

    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        summ=summ+a[i];
        if(summ>m){
            cnt++;
            summ=a[i];
        }
    }

    cout<<cnt+1<<endl;

return 0;
}

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<iostream>
#include<algorithm>
#include<iostream>
#include<algorithm>
#include<iostream>
#include<algorithm>
#include<iostream>
#include<algorithm>
#include<iostream>
#include<algorithm>
#include<iostream>
#include<algorithm>
#include<iostream>
#include<algorithm>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
    int n,m;
    int aa;
    int bb;

    scanf("%d%d",&n,&m);
    int cnt=0;
    int aasn;
    int jkj;
    int dfds;
    int sum=0,ans=1,t;
    while(n--)
    {
        scanf("%d",&t);
        sum+=t;
        if(sum>m)
        {
            ans++;
            if(sum==m)sum=0;
            else sum=t;
        }
    }
    printf("%d\n",ans);
    return 0;
}

#include <iostream>
using namespace std;
int n,sit,i,p,ans;
int main(){
	       cin>>n>>sit;
	       int a[n];
	       for(i=0;i<n;i++){
	       	cin>>a[i];
		   }
		   for(i=0;i<n;i++){
		   	p=p+a[i];
		   	if(p==sit){ans++;p=0;}
		   	if(p>sit){ans++; p=p-a[i]; p=0; i--;}
		   }
		   if(p<sit && p!=0) ans++;
		   cout<<ans;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

int m,n,ans;

int main()
{
    int t=0;
    scanf("%d%d",&m,&n);
    for(int i=0;i<m;i++)
    {
        int x;
        scanf("%d",&x);
        t+=x;
        if(t>n)
        {
            ans++;
            t=x;
        }
    }
    printf("%d",ans+1);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,s,ans=1,a,m;
int main()
{
  cin>>n>>m;
  for(int i=1;i<=n;i++)
  {
    cin>>a;
    s+=a;
    if(s>m)ans++,s=a;
  }
  cout<<ans;
  return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    int arr[n];
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int people=0;
    int count=1;
    for(int i=0;i<n;i++){
        if(people+arr[i]<=m)people+=arr[i];
        else {
            count++;
            people=arr[i];
        }
    }
    cout<<count;

    return 0;
}

#include<iostream>
#include<string>
#include<algorithm>
typedef long long int ll;
using namespace std;
int main()
{
	ll n, a[100000], m, all = 0;;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int bus = 0, c = 0, j;
	for(int i=0;i<n;i++)
	{
		all = a[i];
		j = i + 1;
		while (all < m)
		{
			all += a[j];
			c++;
			j++;
		}
		if (all > m)
		{
			all -= a[j];
			c--;
		}
		bus++;
		i += c;
		c = 0;
	}
		cout << bus;
	return 0;
}

#include <algorithm>
#include <cstdio>
#include <ctime>
#include <cwchar>
#include <iostream>
#include <iterator>
#include <numeric>
#include <vector>
#include <utility>
#include <climits>

using namespace std;

/*int rnd() { return rand() * (RAND_MAX + 1) + rand(); }
template<typename T, int P> struct ct {
    struct nd { ct l, r; int n, c; T x;
        nd(const T &x = T()) : l(), r(), n(1), c(), x(x) {} } *r;
    ct() : r() {}
    ct(const T &x) : r(new nd(x)) {}
    ct(const ct &a) : r(a.r) { psh(); }
    ~ct() { rmv(); }
    ct &operator=(ct a) { return a.psh(), rmv(), r = a.r, *this; }
    void psh() { r && ++r->c; }
    void rmv() { r && !--r->c && (r->l.rmv(), r->r.rmv(), delete r, 0); }
    void cpy() { (r = new nd(*r))->c = 1; }
    int sz() { return r ? r->n : 0; }
    void rcd() {}
    void rcu() { r->n = r->l.sz() + r->r.sz() + 1; }
    ct mrg(ct a) { return mrg(*this, a); }
    template<int M = 0> void spl(ct &l, ct &r, T x) { spl<M>(l, r, *this, x); }
    template<int M = 0> void spi(ct &l, ct &r, int x) { spi<M>(l, r, *this, x); }
    static ct mrg(ct a, ct b) { return a.r ? b.r ? P && (a.cpy(), b.cpy(), 0),
        a.rcd(), b.rcd(), rnd() % (a.sz() + b.sz()) < b.sz() ?
        b.r->l = mrg(a, b.r->l), b.rcu(), b :
        (a.r->r = mrg(a.r->r, b), a.rcu(), a) : a : b; }
    template<int M = 0> static void spl(ct &l, ct &r, ct a, T x) { a.r ?
        P && (a.cpy(), 0), a.rcd(), !M && a.r->x < x || M && !(x < a.r->x) ?
        spl<M>(l, r, a.r->r, x), a.r->r = l, (l = a).rcu(), 0 :
        (spl<M>(l, r, a.r->l, x), a.r->l = r, (r = a).rcu(), 0) :
        (l = r = ct(), 0); }
    template<int M = 0> static void spi(ct &l, ct &r, ct a, int x) { a.r ?
        P && (a.cpy(), 0), a.rcd(),
        !M && a.r->l.sz() < x || M && !(x < a.r->l.sz()) ?
        spl<M>(l, r, a.r->r, x), a.r->r = l, (l = a).rcu(), 0 :
        (spl<M>(l, r, a.r->l, x - a.r->l.sz() - 1), a.r->l = r,
            (r = a).rcu(), 0) :
        (l = r = ct(), 0); }
    ct ins(T x) { ct l, m, r; spl<0>(l, m, x); m.spl<1>(m, r, x);
        return l.mrg(ct(x).mrg(r)); }
    ct ers(T x) { ct l, m, r; spl<0>(l, m, x); m.spl<1>(m, r, x);
        return l.mrg(r); }
    bool fnd(T x) { ct l, m, r; spl<0>(l, m, x); m.spl<1>(m, r, x);
        bool flg = m.sz(); l.mrg(m.mrg(r)); return flg; }
};*/

void tl() {
#ifdef LOCAL
    if (clock() > 1000) {
        cout << "TL";
        exit(0);
    }
#endif
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int n, m, a, b = 0, acc = 0;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        if (acc + a > m) {
            acc = 0;
            ++b;
        }
        acc += a;
    }
    cout << b + 1;

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int n,m,s,x,t[1000000], ans;

int main () {
    cin >> n >> m;
    for(int i = 0; i < n;i++){
        cin >> t[i];
    }
    if(n==1){cout << 1; return 0;}
    ans = 1;
    for(int i = 0;i < n;i++){
        if (x + t[i] > m) {x = t[i]; ans++; continue;}
        x += t[i];
    }
    cout << ans;
}

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{

	int m,n;
	while(cin>>n>>m)
	  {
		  int i,bus=0,sum=0,a[200]={0};
		  if(n==1)
			  bus=1;
		  else
		  for(i=0;i<n;i++)
		    {
				cin>>a[i];
			   sum+=a[i];
			   if(sum>m)
			   {
			      sum=a[i];
				  bus++;

			    }
			   else if(sum==0)
			   {
				   sum=0;
			      bus++;

			   }
		  // cout<<bus<<" "<<sum<<endl;
		    }
		  if(sum)
			  bus++;
	 cout<<bus<<endl;

	}

return 0;
}

#include<iostream>
using namespace std;

int a[105];
int main()
{
    int n,m;
    while(cin>>n>>m)
    {
          int i,j,k;
          for(i=0;i<n;i++)
              cin>>a[i];
          int sum=0;
          int cot=0;
          for(j=0;j<n;j++)
          {
              if(sum+a[j]<=m)
              {
                  sum+=a[j];
                  continue;
              }
              else
              {
                  cot++;
                  j--;
                  sum=0;
              }
          }
          cout<<cot+1<<endl;
    }
    return 0;
}

#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>

#include <deque>
#include <list>
#include <string>
#include <cstdlib>
#include <queue>
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cstring>
#include <assert.h>
#include <stack>
#include <bitset>

#include <complex>

using namespace std;

#define forn(i,j) for(int i = 0; i < int(j); ++i)
#define ford(i,j) for(int i = int(j) - 1; i >= 0; --i)
#define foreach(i,c) for(typeof((c).begin()) i=(c).begin(); i != (c).end(); ++i)
#define debug(x) std::cout << x << std::endl;
#define all(a) (a).begin(), (a).end()
#define sqr(a) ((a)*(a))
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define y1 botva
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

ull gcd(ull x, ull y) {
    return y == 0 ? x : gcd(y, x % y);
}

vector<ll> primes;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> g(n);
    int sum = 0;
    forn(i, n) {
        cin >> g[i];
        sum += g[i];
    }
    int cc = 1;
    int cp = 0;
    int a = m;
    while (sum != 0) {
        if (a - g[cp] < 0) {
            a = m;
            cc++;
        } else {
            a -= g[cp];
            sum -= g[cp];
            cp++;
        }
    }
    cout << cc << endl;

}

#include <iostream>
#include <vector>
using namespace std;
int main() {
	int n, m,ans = 0;
	cin >> n >> m;
	vector<int>a(n);
	for (int i = 0; i < n;i++) cin >> a[i];
	while (!a.empty()) {
		int u = m;
		while (true) {
			if (!a.empty() && (u - a[0]) >= 0) {
				u -= a[0];
				a.erase(a.begin());
			} else {
				ans++;
				break;
			}
		}
	}
	cout << ans;
	return 0;
}

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

typedef long long lld;

const lld maxN = 1000010;
int n, m, t, a[ maxN ];

int main( )
{
    scanf( "%d %d", &n, &m );
    for ( int i = 1; i <= n; i++ ) scanf( "%d", &a[ i ] );
    while ( true )
    {
        int d = m;
        for ( int i = 1; i <= n; i++ )
        {
            if ( d >= a[ i ] )
            {
                d -= a[ i ]; a[ i ] = 0;
            } else break;
        }
        if ( d == m ) break;
        t++;
    }
    printf( "%d\n", t );
    return 0;
}

#include<iostream>
using namespace std;
int main ()
{
  int n , m , people , c=1 , sum=0;
  cin >> n >> m ;
  for(int i=0 ; i<n ; i++)
  {
     cin >> people ;
	if(sum+people<=m)
	   sum+=people;
	else{
	 sum=0;
	 sum+=people;
	 c++;
	}

  }
  cout << c;

  return 0;
}

#include<iostream>
#include<array>
#include<numeric>
#include<algorithm>
#include<vector>
#include<iterator>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define int long long int
using namespace std;
int32_t main(){
    int n,m,s{0},r{0};
    cin>>n>>m;
    for(int i{0};i<n;i++){
        int a;
        cin>>a;
        if(i==n-1){
            s++;
        }
        if(r+a<=m)
            r+=a;
        else{
            r=a;
        s++;}
    }
    cout<<s<<endl;
return 0;
}

#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int g[200];
int main()
{
    int n,m;
    cin>>n>>m;
    int i;
    for(i=0;i<n;i++)
    {
        scanf("%d",&g[i]);
    }
    g[i]=10000;
    int sum=0,left=m;
    for(i=0;i<n;i++)
    {
        if(g[i]<=left)
        {
            left-=g[i];
        }
        else
        {
            sum++;
            left=m;
            i--;
        }
    }
    sum+=1;
    cout<<sum<<endl;
    return 0;
}

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;

const int MAXN = 311111;
const int MAXM = 3111;

int main() {
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);

	int n, m;
	cin >> n >> m;
	int k = 0;
	int f = m;
	while (n--) {
		int x;
		cin >> x;
		if (x > f) {
			k++;
			f = m;
		}
		f -= x;
	}
	cout << k + 1 << endl;

	return 0;
}

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

int main()
{
   int n,ma;
   cin>>n>>ma;
   int arr[n];
   int counter=0;
   int reminder=ma;
   bool in=0;
   for(int i=0;i<n;++i)
   {

       cin>>arr[i];

       }
       for(int i=0;i<n;++i)
       {
           if(arr[i]>ma)counter=0;
           /*
           if(i==n-1)counter++;
           else if(arr[i]<=reminder&&in==0)reminder-=arr[i],in=1;
            else if(arr[i+1]>reminder&&in==1)in=0,counter++,reminder=ma,i--;
            else if(arr[i+1]<=reminder&&in==1)reminder-=arr[i];
*/
            while(arr[i]<=reminder){reminder-=arr[i];i++;}
            i--;counter++;reminder=ma;

       }

   cout<<counter;
    return 0;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <assert.h>

#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define clr(arr, key) memset(arr, key, sizeof arr)
#define pb push_back
#define infinity (1 << 28)
#define LL long long
#define PI acos(-1)
#define gcd(a, b) __gcd(a, b)
#define CF ios_base::sync_with_stdio(0);cin.tie(0);
#define lcm(a, b) ((a)*((b)/gcd(a,b)))
#define all(v) v.begin(), v.end()
#define no_of_ones __builtin_popcount // count 1's in a numbers binary representation
#define SZ(v) (int)(v.size())
#define eps 10e-7

//int col[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//int row[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//int col[4] = {1, 0, -1, 0};
//int row[4] = {0, 1, 0, -1};
//int months[13] = {0, ,31,28,31,30,31,30,31,31,30,31,30,31};

using namespace std;

struct point{int x, y; point () {} point(int a, int b) {x = a, y = b;}};    // for coordinates;

template <class T> T sqr(T a){return a * a;}    // square
template <class T> T power(T n, T p) { T res = 1; for(int i = 0; i < p; i++) res *= n; return res;}     //  n  to the power p
template <class T> double getdist(T a, T b){return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));}    // distance between a and b
template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}    // extract words or numbers from a line
template <class T> string tostring(T n) {stringstream ss; ss << n; return ss.str();}    // convert a number to string
template <class T> inline T Mod(T n,T m) {return (n%m+m)%m;}    // negative mod
template <class T> void print_all(T v) {for(int i = 0; i < v.size(); i++) cout << v[i] << ' ';};
template <class T> void print_all(T &v, int len) {for(int i = 0; i < len; i++) cout << v[i] << ' ';}     // prints all elements in a vector or array
template <class T> void print_pair(T v, int len) {for(int i = 0; i < len; i++) cout << v[i].first << ' ' << v[i].second << endl;} // prints pair vector
//LL bigmod(LL B,LL P,LL M){LL R=1; while(P>0)  {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;}

#define MAX 100010
/*************************************************HABIJABI ENDS HERE******************************************************/

int main()
{
    #ifdef Evan
//        in;
//        out;
    #endif
    int sum = 0, n, m, num, i, res = 0;
    cin >> n >> m;
    for(i = 0; i < n; i++)
    {
        cin >> num;
        if(sum + num < m)
            sum += num;
        else if(sum + num == m)
            sum = 0, res++;
        else
            sum = num, res++;
    }
    cout << res + (sum != 0) << endl;
    return 0;
}

#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <stdio.h>
#include <string>

#define sc scanf
#define pr printf
#define ll long long
#define cmd 1000000007

using namespace std;

int main(){
    int n, k, i, s = 0, d = 0, a[5005];
    cin >> n >> k;
    for(i = 1; i <= n; i++)
        cin >> a[i];
    s = 0;
    int x = 1;
    for(i = 1; i <= n; i++){
        s = s + a[i];
        if(s > k) {d++; s = a[i];}
    }
    cout << d + 1;
    return 0;
}

#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int n, m, x, count = 1, sum = 0;
	cin >> n >> m;
	for (int i = 0; i < n; i++){
		cin >> x;
		if (sum + x <= m){
			sum += x;
		}
		else{
			sum = x;
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    int n,m,p=0,q=0,t;
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        cin>>t;
        p=p+t;
        if(p>m)
        {
            q++;
            p=t;
        }
    }
    if(p)
        q++;
    cout<<q;
    return 0;
}//2018-11-27 17:36:22.928

#include<iostream>
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	int c = 0;
	int k = 0;
	int x[100];
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		k += x[i];
		if (k == m)
		{
			k = 0;
			c++;
		}
		else if (k > m)
		{
			k = x[i];
			c++;
		}

	}
	if (k != 0)
		c++;
	cout << c;
}

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {

    int n, m;
    cin >> n;
    cin >> m;
    int el;
    vector<int> v;
    int ans = 0;

    for (int i = 0; i < n; i++) {
        cin >> el;
        v.push_back(el);
    }

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

        if (sum + v[i] == m) {
            ans++;
            sum = 0;
        } else if (sum + v[i] > m) {
            ans++;
            sum = v[i];
        } else {
            sum += v[i];
        }
    }

    //    cout << "sum = "<< sum<< endl;

    if (sum > 0) ans++;
    cout << ans;
    return 0;

}

#include <iostream>

using namespace std;

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

    int cnt = 1, left = m;
    for (int i=0; i<n; i++)
    {
        int tmp;
        cin >> tmp;
        if (tmp > left)
        {
            left = m;
            cnt++;
        }
        left -= tmp;
    }

    cout << cnt << endl;

    return 0;
}

#include <iostream>
using namespace std;
//ifstream cin("input.txt"); ofstream cout("output.txt");
void main()
{
	int k=0,i,n,m,a[101]={0},sum=0; cin>>n>>m;
	for(i=1;i<=n;i++)
		cin>>a[i];
	for(i=1;i<=n;i++)
	{
		if (a[i]==m) { k++; continue; }
		else
		{
			sum=a[i];
			while (sum+a[i+1]<=m)
			{
				if(a[i+1]==0) break;
				sum+=a[i+1]; i++;
			}
			k++;
		}
	}
	cout<<k;
}

#include<iostream>

using namespace std;

int main()
{
    int n, m;

    cin >> n >> m;

    int ans = 0, val, sum = 0;

    for(int i = 1; i <= n; i++)
    {
        cin >> val;

        sum += val;

        if(sum >= m)
        {
            ans++;

            if(sum == m) sum = 0;
            else sum = val;

            if(sum == m) ans++, sum = 0;
        }
    }

    if(sum) ans++;

    cout << ans;
}

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn=1000005;
LL num1[maxn],num2[maxn];

int main()
{
    int n,m,sum=0,t,ans=1;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&t);
        if(sum+t>m)
        {
            ans++;
            sum=t;
        }
        else
            sum+=t;
        //sum+=t;
    }
    //sum=sum%m==0?sum/m:sum/m+1;
    printf("%d\n",ans);
    return 0;
}

#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <climits>
#include <cfloat>
#include <utility>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <iterator>
#include <complex>
#include <queue>
#include <stack>
#include <cctype>
#include <memory>
#include <ctime>
#include <bitset>
#include <deque>
#include <sstream>
#include <string>
#include <list>
#include <numeric>
#include <iomanip>

using namespace std;

typedef long long LL,ll;
typedef unsigned long long ULL,ull;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector< vector<int> > vvint;
typedef vector<ll> vll,vLL;
typedef vector< vector<ll> > vvll,vvLL;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define REPD(i,n) for(int i=(int)(n-1);i>=0;i--)
#define cases(t) while(t--)

#define mod 1
#define EPS 1e-8

//------------------------------------------------------------------------//

int a;

int main(){
	int n,m,sm=1;
	scanf("%d%d",&n,&m);
	int tmp=0;
	REP(i,n){
        cin >> a;
        if(tmp+a<=m) {
                tmp+=a;
        }
        else{
            sm++;
            tmp=a;
        }
    }

	cout << sm << "\n";
	return 0;
}

#include <iostream>
using namespace std;
main()
{
   bool s;
   int mn[105] , m , n , k , l , cnt=0 , ans=0;
   cin>>n>>m;
   for(int i=1; i<=n; i++)
   {
     cin>>k;
     cnt+=k;
     if(cnt==m || (cnt>0 && i==n && cnt<=m))
      { cnt=0; ans++; }
     if(cnt>m)
      { cnt=k; ans++;  }
   }
   if(cnt>0)
   ans++;
   cout<<ans<<endl;  return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, m, s = 0, k = 0;
    cin >> n >> m;
    for(int i=1; i<=n; ++i){
        int x;
        cin >> x;
        s += x;
        if(s > m)
            k ++, s = x;
        if(s == m) k ++, s = 0;
    }
    if(s > 0) k ++;
    cout << k << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define endl "\n"
#define pb push_back
#define mp make_pair
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
		int n,k,m,ans=0,r=0,sum=0,i,flag=0;
		cin>>n>>m;
		int a[n];
		for(i=0;i<n;i++)
		cin>>a[i];
	    for(i=0;i<n;i++){
	    	 //if(a[i]<m)
	    	 sum+=a[i];
	    	 if(sum<m)
	    	 continue;
	    	 if(sum==m){
	    	 ans++;
	    	 sum=0;}
	    	 if(sum>m){
	    	 	sum=0;
	    	 	ans=ans+1;
	    	 	i--;
	    	 //	cout<<a[i];
	    	 }
	    	// if(a[i]>=m){
	    	 //ans=ans+a[i]/m+((a[i]%m)!=0);}
	    }
	    if(sum>0){
	    	ans=ans+a[n-1]/m+((a[n-1]%m)!=0);
	    }
	    if(ans==0)
	    cout<<"1"<<endl;
	    else
	    cout<<ans<<endl;

 return 0;
}

# include <stdio.h>

int a[110];

int main ()
{
    int n, m, bus, ans, i;
    while (~scanf ("%d%d", &n, &m))
    {
        for (i = 0; i < n; i++)
            scanf ("%d", &a[i]);
        bus = m;
        ans = 1;
        for (i = 0; i < n; i++)
        {
            if (bus >= a[i])
                bus -= a[i];
            else
                bus = m - a[i], ans++;
        }
        printf ("%d\n", ans);
    }
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <bits\stdc++.h>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define sz(s) (int)(s.size())
#define exit(s) return cout<<s,0;
#define F first
#define S second
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);//freopen("out.txt", "w", stdout);
#endif
}

int main() {
	Fast;
	file();
	int n, m, x = 0, c = 1;
	cin >> n >> m;
	while (n--) {
		int a;
		cin >> a;
		if (a + x <= m)
			x += a;
		else {
			x = a;
			c++;
		}
	}
	cout << c;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main() {
    int n, m, s = 0, cnt = 0;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        s += x;
        if (s > m) {
            ++cnt;
            s = x;
        }
    }
    printf("%d\n", ++cnt);
    return 0;
}

#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cstring>
#include <queue>
#include <deque>
#include <functional>
#include <climits>

#define mp make_pair
#define mt(a, b, c) mp(a, mp(b, c))
#define ABS(a) (((a) > 0) ? (a) : (-(a)))
#define ZERO(x) memset((x), 0, sizeof(x))
#define X first
#define Y second

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> ii;

int main()
{
#ifdef XXX
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n, m;
	cin >> n >> m;

	int ans = 1;
	int cur = m;
	for (int i = 0; i < n; i++)
	{
		int t;
		cin >> t;
		if (cur >= t)
		{
			cur -= t;
			continue;
		}
		if (cur < t)
		{
			cur = m - t;
			ans++;
		}
	}

	cout << ans;

	return 0;
}

//
//  main.cpp
//  Codeforces Round #249 (Div. 2) - A. Queue on Bus Stop
//
//  Created by S M HEMEL on 3/28/17.
//  Copyright © 2017 Eastern University. All rights reserved.
//

#include <iostream>
#include <cmath>
using namespace std;
int a[100];
int main()
{
    int n,m,cnt = 0;
    cin >> n >> m;
    for(int i=0; i<n; cin >> a[i],i++);
    int temp = 0;
    if(n==1)
        return 0 * puts("1");
    for(int i=0; i<n; i++)
    {
        if((temp+a[i])<m){
            if(i==(n-1)){
                cnt++;
                cout << cnt << endl;
                return 0;
            }
            temp += a[i];
            continue;
        }
        if((temp+a[i])>m){
            temp = a[i],cnt++;
            if(i==(n-1)){
                cnt++;
                cout << cnt << endl;
                return 0;
            }
            continue;
        }
        if((temp+a[i])==m){
            temp = 0,cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int m,n,last=0,a,ans=0;
	cin>>n>>m;
	while(n--)
	{
		cin>>a;
		if (a+last<=m) last+=a;
		else
		{
			ans++;
			last=a;
		}
	}
	if (last!=0) ans++;
	cout<<ans<<endl;
	return 0;
}

/*
“As I know, madness is like gravity...all it takes is a little push.”
Har Har mahadev!
Hey Mahakaal please make best Human being as possible

*/

#include<bits/stdc++.h>
#define pb push_back
#define ll long long int
#define ld long double
#define vsort(v) sort(v.begin(),v.end())
#define vrsort(v) sort(v.begin(),v.end(),greater<int>())
#define mset(a) memset(a,0,sizeof(a))
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define mm 100005
#define out(a) for(auto x:a) cout<<x<<" ";
#define sp(arr) sort(arr,arr+sizeof(arr)/sizeof(arr[0]));
#define bolt ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main()
{

    {
        ll n,m;
    cin>>n;
    cin>>m;
    ll sum=0;
    ll c=1;
    rep(i,n)
    {

        ll x;
        cin>>x;
        if(sum+x<=m)
        {
            sum+=x;
        }
        else{
          c++;
          sum=x;
        }
    }
   cout<<c<<endl;

    }
}

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,a,b,d) for(int i=a; i<=b; i+=d)
#define repd(i,a,b,d) for(int i=a; i>=b; i-=d)
#define repi(it,stl) for(auto it = (stl).begin(); (it)!=stl.end(); ++(it))
#define sz(a) ((int)(a).size())
#define mem(a,n) memset((a), (n), sizeof(a))
#define all(n) (n).begin(),(n).end()
#define rall(n) (n).rbegin(),(n).rend()
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define vi vector<int>
#define vs vector<string>
#define sstr stringstream
#define indexof(v,x) (find(all((v)),(x))-(v).begin())

typedef long long ll;
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("main.txt","rt",stdin);
    //  freopen("out.txt","wt",stdout);
#endif

    int n,m,rem=0,res=0,x;
    cin >> n >> m;
    rep(i,n) {
        cin >> x;
        if(rem + x <=m)
            rem += x;
        else{
            res++;
            rem = x;
        }
    }
    if(rem) ++res;
    cout << res;
    return 0;
}

#include<iostream>
using namespace std;
int main(){
	int m,n,a[110],tmp,ans=0;
	cin>>n>>m;
	for(int i=0;i<n;i++)
		cin>>a[i];

	for(int i=0;i<n;i++){
		if(!a[i])continue;
		tmp=m-a[i];
		a[i]=0;
		for(int j=i+1;j<n;j++){
			if(!tmp||tmp<a[j]){
				ans++;
				break;
			}
			if(!a[j])continue;
			tmp-=a[j];
			a[j]=0;

		}

	}
	ans++;
	cout<<ans<<endl;
return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#define MAX 107
using namespace std;
typedef long long ll;
int a[MAX];
int main()
{
	int n,m;
	while(~scanf("%d%d",&n,&m))
	{
		int cnt = 1;
		int cur = m;
		for(int i = 0;i < n;i++)
		{
			scanf("%d",a+i);
			if(m >= a[i])
				m -= a[i];
			else
			{
				m = cur -a[i];
				cnt++;
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

#include <stdio.h>
int a[101];
int main()
{
	int n, m, s, t;
	while(scanf("%d%d", &n, &m) != EOF)
	{
		s = 0;
		for(int i = 0; i < n; i++)
		{
			scanf("%d", &t);
			if(t % m)
				s += t / m + 1;
			else
				s += t / m;
		}
		printf("%d\n", s);
	}
	return 0;
}

#include<algorithm>
#include<iostream>
#include<fstream>
#include<cstring>
#include<utility>
#include<cstdlib>
#include<iomanip>
#include<sstream>
#include<string>
#include<cstdio>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<ctime>
#include<cmath>
#include<set>
#include<map>

#define DEB 1
#define L first
#define R second
#define LL long long
#define PB push_back
#define MP make_pair
#define Size(c) ((int)(c).size())
#define For(i, c) for(__typeof(c.begin()) i=c.begin();i!=c.end();++i)
#define E(x) if(DEB) cerr<<#x<<" : "<<x<<endl

using namespace std;
typedef pair<int, int> pie;

const int Maxn = 1e6+10000;
int n, m, now, ted;
int main(){
  ios_base::sync_with_stdio(false);
  cin>>n>>m;
  now = m;
  while(n--){
    int fi;
    cin>>fi;
    if(now > fi)
      now -= fi;
    else
      now = m - fi, ted ++ ;
  }
  cout<<ted<<endl;
  return 0;
}

#include <iostream>
#include <string>
using namespace std;
int main()
{
	int m,n,arr[100],bus=0,sum=0;
	cin>>n>>m;
	for(int i=0;i<n;i++)
		cin>>arr[i];
	for(int i=0;i<n;i++)
	{
		sum+=arr[i];
		if(sum>=m)
		{
			sum=arr[i];
			bus++;
		}
		if(sum<m && i==n-1)
			bus++;

	}
	cout<<bus<<endl;

	return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int n , m , sum = 0 , b , count1 = 1;
    cin >> n >> m ;
    for(int i = 0 ; i < n ; i++)
    {
        cin >> b ;
        if(b + sum > m)
            count1++;
        else
            sum += b ;
    }
   cout << count1 << "\n";
    return 0;
}

/*
“As I know, madness is like gravity...all it takes is a little push.”
Har Har mahadev!
Hey Mahakaal please make best Human being as possible

*/

#include<bits/stdc++.h>
#define pb push_back
#define ll long long int
#define ld long double
#define vsort(v) sort(v.begin(),v.end())
#define vrsort(v) sort(v.begin(),v.end(),greater<int>())
#define mset(a) memset(a,0,sizeof(a))
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define mm 100005
#define out(a) for(auto x:a) cout<<x<<" ";
#define sp(arr) sort(arr,arr+sizeof(arr)/sizeof(arr[0]));
#define bolt ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main()
{

    {
        ll n,m;
    cin>>n;
    cin>>m;
    ll sum=0;
    rep(i,n)
    {

        ll x;
        cin>>x;
        sum+=x;
    }
    if(sum%m==0) cout<<sum/m<<endl;
    else cout<<(sum/m)+1<<endl;

    }
}

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int n,m;
    int a[100];
    while(cin>>n>>m)
    {
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        int s=0;
        for(int i=0;i<n;i++)
        {
            s+=a[i];
        }
        if(s%m==0)
            cout<<s/m<<endl;
        else
            cout<<(s/m)+1<<endl;
    }
    return 0;
}

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,a,b,d) for(int i=a; i<=b; i+=d)
#define repd(i,a,b,d) for(int i=a; i>=b; i-=d)
#define repi(it,stl) for(auto it = (stl).begin(); (it)!=stl.end(); ++(it))
#define sz(a) ((int)(a).size())
#define mem(a,n) memset((a), (n), sizeof(a))
#define all(n) (n).begin(),(n).end()
#define rall(n) (n).rbegin(),(n).rend()
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define vi vector<int>
#define vs vector<string>
#define sstr stringstream
#define indexof(v,x) (find(all((v)),(x))-(v).begin())

typedef long long ll;
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("main.txt","rt",stdin);
    //  freopen("out.txt","wt",stdout);
#endif

    int n,m,sum=0,x;
    cin >> n >> m;
    rep(i,n) cin >> x, sum += x;
    cout << (sum+m-1)/m;

    return 0;
}

#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <ctype.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <stdio.h>
#define File_in(input) freopen(input, "r", stdin)
#define File_out(output) freopen(output, "w", stdout)
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int,int> point;
const int ms = 1e5+10;
const int mod = 1000000007;
const ll inf = 2147483645;

bool cmp (point p1, point p2) {
  return p1.first > p2.first;
}

int main () {
    //File_in("input.txt"); File_out("output.txt");
    ios_base::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    int a[111] = {0};
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    int t = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans+=(a[i]/m);
        a[i+1] += a[i] % m;
    }
    ans+=(a[n]/m);
    if (a[n] % m > 0)
        ans++;
    cout << ans << endl;
}

//be name  khoda
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
int main()
{
	int n,m;
	cin>>n>>m;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int sum=0;
	int f=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]==m)
		{
			sum++;
		}
		else
		{
			if(f+a[i]>=m)
			{
				sum++;
				f=f+a[i]-m;
			}
			else
			{
				f+=a[i];
			}
		}
	}
	if(f!=0)
		sum++;
	cout<<sum;
}

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

int main(){
    int n, m, a[101], res = 0, sum = 0;
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        res += a[i] / m;
        a[i] %= m;
        sum += a[i];
    }
    cout << ceil(sum*1./m) + res << endl;
    return 0;
}

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

int main()
{
    long int n,m,group,ans=1,left;
    cin>>n>>m;
	group=m;
    for(int i=0;i<n;i++)
	{
		cin>>group;
		if(group<=left)
			left=left-group;
		else
		{
			ans++;
			left=m;
			left=left-group;
		}
	}
	cout<<ans;
}

#include <iostream>
#include<string.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
 float n,m,a,c=0;
 cin>>n>>m;
 for(int i=0;i<n;i++){
    cin>>a;
    c+=a;
 }
 cout<<ceil(c/m);

    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <cmath>
#include <string>
#include <iomanip>
#include <math.h>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>

#define ll long long
#define st string
#define fi first
#define se second
#define pb push_back

using namespace std;

const ll N = 2e9 + 10;
const ll INF = 1e18;
const ll inf = -1e18;
const ll MOD = 1e9 + 7;
const ll base = 1000 * 1000 * 1000;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
    #define eprintf(...) 42
#endif

int gcd (int a, int b) {
        while ( b ) {
            a %= b;
            std::swap (a, b);
        }
            return a;
}

int lcm (int a, int b) {
        return a / gcd (a, b) * b;
}
map < int, int > us;
void solve() {
    int n, m;
    cin >> n >> m;
    vector < int > v(n);
    for ( int i = 0; i < n; ++i )cin >> v[i];
    cout << n << "\n";

}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); std::cout.tie(0);

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

//    int T;cin >> T;
//    while ( T-- ){
        solve();
//    }

}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,sum=0,a1,i,x1=0,a[1009];
    cin>>n>>m;
    for(i=0; i<n; i++)
    {
        cin>>a[i];

    }
    sort(a,a+n);
    x1=0;
        for(i=0; i<n; i++)
        {
            sum=sum+a[i];
            if(sum<m && i==(n-1))
            {
                x1++;
            }
            else if(sum==m)
            {
                x1++;
                sum=0;
            }
            else if(sum>m)
            {
                x1++;
                i--;
                sum=0;
            }
        }
        cout<<x1;
}

#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdlib>
#include <set>

#define sz(c) (int)c.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LL long long
#define mod (int)1e9+7

using namespace std;

int n, m, a;
int ans = 1, cur;

int main() {
    ios_base::sync_with_stdio(0);
    //freopen("input.in", "r", stdin);
    //freopen("output.txt", "w", stdout);

    scanf("%d %d", &n, &m);

    for(int i = 0; i < n; i++) {
        scanf("%d", &a);
        cur += a;
        if(cur > m) {
            ans++;
            cur -= a;
        }
    }

    printf("%d\n", ans);

    return 0;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <limits>
#include <cmath>
#include <cstdlib>
#include <string.h>
#include <ctime>

using namespace std;

#define VI vector<int>
#define VVI vector<VI >
#define VB vector<bool>
#define VVB vector<VB >
#define VC vector<char>
#define VVC vector<VC >
#define VS vector<string>
#define PII pair<int, int>
#define VPII vector<pair<int, int> >
#define REP(var, startFrom, endTo) for(int var = startFrom; var < (int)endTo; ++var)

template <typename T>
inline const T MAX(T a, T b) { return ((a) > (b) ? (a) : (b)); }
template <typename T>
inline const T MIN(T a, T b) { return ((a) > (b) ? (b) : (a)); }
template <typename T>
inline const T ABS(T a) { return (((a) > 0) ? (a) : (-(a))); }

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("tmp.in", "r", stdin);
	//	freopen("tmp.out", "w", stderr);
#endif
	int n, m;
	cin >> n >> m;

	int sum = 0;
	for (int i = 0; i < n; ++i)
	{
		int num;
		cin >> num;

		sum += num;
	}

	if (sum <= m)
		cout << 1 << endl;
	else if (sum % m == 0)
		cout << sum / m << endl;
	else
		cout << sum / m + 1 << endl;

	return 0;
}

#include "iostream"
using namespace std;
int k=0 , sum=0 , a[1000000];
int n , m , sum2=0 , p=0;
int main()
{
cin>>n>>m;
for (int i=0; i<n; i++)
cin>>a[i];
a[n]=0;
for (int i=0; i<n; i++)
sum2+=a[i];
if (sum2<=m) { cout<<1; return 0; }
else {
sum=a[0];
if (sum>=m) { k++; sum-=m; }
for (int i=0; i<=n; i++)
{
	sum+=a[i+1];
	if (sum>=m) { k++; p=sum-a[n-1]; sum=0; }
	else continue;
}
}
if (p>0) cout<<k+1;
else
cout<<k;

	return 0;
}

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {

    int n, m;
    cin >> n;
    cin >> m;
    int el;
    vector<int> v;
    int ans = 0;

    for (int i = 0; i < n; i++) {
        cin >> el;
        v.push_back(el);
    }

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

        if (sum + v[i] == m) {
            ans++;
            sum = 0;
        } else if (sum + v[i] > m) {
            ans++;
            sum = v[i];
        } else {
            sum += v[i];
            continue;
        }
    }

    cout << ans;
    return 0;

}

//be name  khoda
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
int main()
{
	int n,m;
	cin>>n>>m;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int sum=0;
	int f=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]==m)
		{
			sum++;
		}
		else
		{
			int t=a[i];
			int flag=0;
			int s=sum;
			for(int j=i+1;j<n;j++)
			{
				t+=a[j];
				if(t>=m)
				{
					sum++;
					break;
				}
				else
				{
					a[j]=0;
				}
			}
		}
	}
	if(sum==0)
		sum++;
	cout<<sum;
}

#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n,m,tmp,tmp_m,c=0;
    vector<int> v;

    cin>>n>>m;
    tmp_m=m;
    for(int i=0;i<n;i++){
        cin>>tmp;
        tmp_m-=tmp;
        if(tmp_m<0){
            v.push_back(tmp);
            c++;
            tmp_m=m;
        } else if(tmp_m==0){
            c++;
        }
        while(v.size()!=0){
            tmp_m-=v.back();
            v.pop_back();
        }
    }
    cout<<c;
    return 0;
}

#include<stdio.h>
#include<string.h>

int main()
{
    int n, m;
    while(~scanf("%d%d", &n, &m))
    {
        int ans = 1, t = 0;
        int x;
        while(n--)
        {
            scanf("%d", &x);
            if(t + x >= m)
            {
                ans ++;
                t = x;
            }
            else
            {
                t += x;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}

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

long long d,v,a,num1,num2,r,b,c,k,s,t,j,i,l,n,w,h[1000000],m[1000000];
pair <long long, long long> x[11111];
pair <long long, long long> y[11111];
pair <long long, long long> z[11111];
string q[1000000],p;
char e;

int main() {

    cin >> a  >> b;
    for (i=0;i<a;i++){
        cin >> m[i];

    }
    sort (m,m+a);

    for (i=0;i<a;i++){
        if (s>=b){c++;s=0;}
        s+=m[i];
    }
    cout << c;

}

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stdlib.h>
using namespace std;

int main()
{
    int i,j,n,m;
    int str[105];
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        for(i=0;i<n;i++)
        {
            scanf("%d",&str[i]);
        }
        sort(str,str+n);
        int sum=0,cas=0;
        for(i=0;i<n;i++)
        {
            cas=0;
            while(cas<m)
            {
                cas+=str[i];//printf("%d*\n",str[i]);
                if(cas+str[i+1]<m)
                {
                    i++;
                }
                else if(cas+str[i+1]==m)
                {
                    i++;
                    sum++;break;
                }
                else
                {
                    sum++;
                    break;
                }

                //i++;
            }
            //sum++;
        }
        printf("%d\n",sum);
    }
}

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,sum=0,p=0,l=0,a=0;
	cin>>n>>m;
	int num[n];
	int y=n;
	int size[n];
	int arr[n][n];
	for(int i=0;i<n;i++){
		cin>>num[i];

	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
		       arr[i][j]=0;
		  }
	}

			for(int i=0;i<n;i++){
		for(int j=a;j<n;j++){
			arr[i][j]+=num[j];
			arr[i][j+1]+=arr[i][j];
		}
		a=i+1;
		arr[i][0]=0;
	}
		for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(arr[i][j]==m){
				l++;
				j=n;
			}
			if(arr[i][j]>m){
				l++;
				j=n;
			}

	}
}

	cout<<l<<endl;

}

#include <iostream>

using namespace std;

int main()
{
    int n , m  , counter = 0 , s=0 ;
    cin>>n>>m;
    int array1[n];
    for (int i = 0 ; i<n ; i++){
        cin>>array1[i];
    }
    for (int y = s ; y<n ; y++){
            int sum=array1[y];
            for (int z = y+1 ; z<n ; z++){
                sum = sum+array1[z] ;
                if (sum > m ){
                        s=z;
                     break;
                }
            }
           counter++;
           if (sum <= m)
            break ;
    }
    cout<<counter;
}

#include<iostream>
#include<string>
#include<algorithm>
#include<cstring>
using namespace std;

int main()
{
   int n,m,sum=0;
   cin >> n >> m;
   int a[n];
   for(int i=0;i<n;i++){
   cin >> a[i];
   sum=sum+a[i];
   }
   if((sum%m)==0)
   cout << sum/m;
   else
   cout << sum/m+1;
   return 0;
}

#include<iostream>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int* a=new int[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}

int sum=a[0];
int k=0;
for(int i=0;i<n;i++)
{
if(sum+a[i]>m)
{k++;
sum=a[i];
}
else
{sum=sum+a[i];
}
}
if(a[n-2]+a[n-1]>m)
k++;
cout<<k;

}

#include<iostream>
#include <vector>
#include <math.h>
using namespace std;
int main(){
    int n,m,sum=0,a[105];   cin >> n >> m;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum+=a[i];
    }
    if(sum%m == 0){
        cout << sum/m <<"\n";
    }
    else{
        cout << (sum/m)+1 << "\n";
    }
    return 0;
}

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

int n, m, k, maxi, mini, a[100000], b[100000], dp[1000][1000];
string s;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    scanf("%d %d",&n,&m);
    int ans = 0;
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }

    int sum = 0;
    for(int i=0; i<n; i++)
    {
        if(sum + a[i] <= m)
        {
            sum += a[i];
        }
        else
        {
            sum = 0;
            ans++;
        }
    }

    cout<<ans;

return 0;
}

#include <vector>
#include <string>
#include <cstring>
#include <iostream>
#include <stdlib.h>
#include <algorithm>

using namespace std;

int main() {
	int N, M;

	cin >> N >> M;

	vector<int> A;
	A.resize(N);

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

	int res = 0;
	size_t i = 0;
	while (i < N) {
		res++;
		int t = 0;
		do {
			i++;
			t+=A[i];
		} while (i < N && A[i] + t <= M);
	}

	cout << res << endl;

	return 0;
}

// #include <bits/stdc++.h> // At the cost of compilation time
#include <iostream>
#include <algorithm>
#include <set>
#include <iterator>
#include <vector>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <math.h>
#include <deque>
#include <unordered_map>
#include <unordered_set>

#define us unordered_set
#define um unordered_map
#define ll long long
#define pii pair<int, int>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 1e18

#define fo(n) for (int i = 0; i < n; i++)
#define deb(x) cout << #x << " = " << x << endl
#define debp(x, y) cout << #x << " = " << x << " ," << #y << " = " << y << endl
#define all(x) x.begin(), x.end()
#define tr(a) for (auto it = a.begin(); it != a.end(); it++)
using namespace std;

void set_io()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
}

int main()
{
    // set_io();
    int n,m, buses;
    cin>>n>>m;
    // int arr[n];
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        int num;
        cin>>num;
        sum += num;
    }

    cout<<sum%m + 1<<endl;

}

#include<iostream>
#include<algorithm>
using namespace std;
int main ()
{

  int n , m , search[101] , c=0 , sum=0;
  cin >> n >> m;
  for(int i=0 ; i<n ; i++)
  {
     cin >> search[i];
	 if(search[i]==m)
	 {
	    c++;
		search[i]=0;
	 }
	 if(c==n)
	 {
	   cout << c;
	   return 0;
	 }
  }
  sort(search , search+n);
  for(int i=0 ; i<n  ; i++)
      if(search[i]!=0)
	     sum+=search[i];
  sum-=m;
  if(sum<=0)
     c++;
  else
     c+=sum;
  cout << c;

  return 0;
}

#include <iostream>
using namespace std;
int main()
{
 int x,y,a,c=0;
 cin>>x>>y;
 for(int i=0;i<x;i++)
 {
     cin>>a;
     c+=a;
 }
 if(c%y==0)
    cout<<c/y;
 else if(c%y!=0)
    cout<<int (double(c)/y)+1;

    return 0;
}

#include<iostream>
using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    int peopleno[100];
    int sum=0;
    int x=0;
    for(int i=0;i<n;i++){
        cin>>peopleno[i];
        sum+=peopleno[i];
        if(sum>=m){
            sum=peopleno[i];
            x++;
        }
    }

    cout<<x<<endl;

    return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <utility>
#include <set>
#include <math.h>
using namespace std;
int main()
{
   int suma=0;
   int buses=0;
   int n,c;
   int pers;
   cin>>n>>c;

   for(int i=0;i<n;i++)
   {
     cin>>pers;
     suma=suma+pers;
	 if(suma>=c || i==n-1)
	 {
	   suma=suma-c;
	   buses++;
	 }

   }
   cout<<buses<<endl;
return 0;
}

#include <bits/stdc++.h>

using namespace std;

int n,m,s,x,t[1000000];

int main () {
    cin >> n >> m;
    for(int i = 0; i < n;i++){
        cin >> t[i];
    }
    if(n==1)cout << 1;
    else{
    for(int i = 0;i < n;i++){
        //cout << t[i] << endl;
        for(int j = i;j < n;j++){
            x+=t[j];
            if(x > m){s++;i=j-1;x=0;break;}
            else if(x == m){s++;i=j;x=0;break;}
        }
    }
    cout << s;
    }
}

#include <iostream>
using namespace std;

int main()
{
    int n, m;
    int *a;
    int sum = 0, j = 0;
    cin >> n >> m;
    a = new int[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
    {
        if (sum < m)
        {
            sum = sum + a[i];
            if (i == n - 1)
                j++;
        }
        if (sum > m)
        {
            j++;
            i--;
            sum = 0;
        }
        if (sum == m)
        {
            j++;
            sum = 0;
        }
    }
    cout << j;

    return 0;
}

#include<cstdio>
#include<iostream>
using namespace std;
int main ()
{
	int n,m;
	cin>>n>>m;
	int i,a[m],sum=0,cnt=0;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++)
	{
		if(sum+a[i]<m)
		{
			sum=sum+a[i];
		}
		else
		{
			cnt++;
			sum=a[i];
		//	sum=sum+a[i]-m;
		}
	}
//	if(sum==0)
//	{
		cout<<cnt<<endl;
//	}
//	else
//	{
	//	cnt++;
	//	cout<<cnt<<endl;
//	}
		return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int n,m,item,temp,c=0,sum=0,a;
    cin>>n>>m;
    while(n--)
    {
        cin>>a;
        sum+=a;

    }
   /// cout<<sum<<endl;

    if(sum%m==0)
        cout<<sum/m<<endl;
    else
        cout<<sum/m +1<<endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int  MOD=1000000007;

int main()
{
    ios_base::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    int sum=0;
    for(int i=0;i<n;i++){
        int y;
        cin>>y;
        sum+=y;
    }
    int res=(sum + (m - 1)) / m;
    cout<<res<<"\n";

    return 0;

}

#include <iostream>
#include <vector>
using namespace std;
int main ()
{
    int a,b=0,d,e,f,g,h=0,t;
    vector <int> c;
    cin>>a;
    cin>>e;
    f=e;
    while (b<a)
    {
          cin>>d;
          c.push_back (d);
          b++;
          }
          t=b;
          b=0;
          while (t>0)
          {
          while (b<c.size())
          {
                if (e>=c[b]) {e=e-c[b];t--;c[b]=-1;}
                b++;
                }
              h++;
              e=f;
              b=0;
              }
                cout<<h<<endl;
    return 0;
}

#include <iostream>
using namespace std;
int n,h[110],m,t=0,s=0;
int main()
{
    cin>>n>>m;
    for (int i=0;i<n;i++)
    cin>>h[i];
    for (int i=0;i<n;i++)
        if (s+h[i]<=m) s+=h[i];
        else
        {
                    if (i<n-1) s=h[i]; else t++;
                    t++;
        }
    if (t>0) cout<<t; else cout<<"1";
}

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<string.h>
using namespace std;
int main()
 {
     int n,m,i,ans=0,x=0,a[105];
     cin>>n>>m;
     for(i=0;i<n;i++)
     cin>>a[i];
     for(i=0;i<n;i++)
      {
       x=x+a[i];
       if(x==m)
       {x=0;ans++;}
       if(x>m)
       {x=0;x=x+a[i];ans++;}

      }
      if(x!=0&&x<m)
      ans++;
     cout<<ans;
     return 0;

 }

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <utility>
#include <set>
#include <math.h>
using namespace std;
int main()
{
   int suma=0;
   int buses=0;
   int n,c;
   int pers;
   cin>>n>>c;

   for(int i=0;i<n;i++)
   {
     cin>>pers;
     suma=suma+pers;
	 if(suma>c || i==n-1)
	 {
	   suma=pers;
	   buses++;
	 }
   }
   cout<<buses<<endl;
return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int n;
    int m;
    int a[100];
    int S = 0;
    int B = 0;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        S = S + a[i];
    }
    if (S > m)
    {
        B = (S / m) + 1;
    }
    else
    {
        B = (S / m);
    }
    cout << B << endl;
}

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <numeric>
using namespace std;
const int N = 1e2+10;

int n, m, a[N];

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.in", "r", stdin);
#endif
  for ( ; ~scanf("%d%d", &n, &m); ) {
    for (int i = 0; i < n; i++)
      scanf("%d", a+i);
    printf("%d\n", (accumulate(a, a+n, 0)+m-1)/m);
  }
  return 0;
}

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

#include <iostream>
#include<algorithm>
using namespace std;

int main()
{
    int arr[1001];
    int x,y,n=0,m=0,sum=0;
    cin>>x>>y;
    for(int i=0;i<x;i++)
    {
        cin>>arr[i];
    }
sort (arr,arr+x);

reverse(arr,arr+x);
if(x!=1)
{

for(int i=0;i<x-1;i++)
{

     if(arr[i]==y)
        n++;
     else if (arr[i]+arr[i+1]==y)
        n++;
     else if (arr[i]+arr[i+1]>y)
        n++;
     else if (arr[i]+arr[i+1]<y)

        {

            for(int j=i;j<x;j++)
            {
                sum+=arr[j];
                m=j;

                if (sum==y)
                {
                    n++;
                    i=m;
                    break;

                }
               /* else if (sum>y)
                {
                    n++;

                }

                */

            }

     }

}

    cout<<n;

}else
{

    if(arr[0]==y||arr[0]<y)
        n++;

    else if (arr[0]>y)
      {

        n++;

    if(arr[0]%y!=0)
        n++;

    }

    cout<<n;

}

    return 0;
}

#include <iostream>

using namespace std;

int main()
{
	float n,m,sum=0,x;
	cin>>n>>m;
	for(int i=0;i<n;++i)
	{
		cin>>x;
		sum+=x;
	}
	int y=sum/m;
	float h=sum/m;
	if((h-y)!= 0)
		cout<<++y<<endl;
	else
		cout<<y<<endl;
	return 0;
}

#include <iostream>
using namespace std;
int main()
{
    int N, m;
    cin >> N >> m;
    int avt = 0;
    int * a = new int [N];
    for (int i = 0; i < N; i++)
        cin >> a[i];
    int pred = 0;
    for (int i = 0; i < N; i++)
    {
        pred += a[i];
        if (pred >= m)
        {
            avt++;
            pred = 0;
            if (a[i] == m)
                avt++;
            else pred = a[i];
        }
    }
    if (pred)
        avt++;
    cout << avt;
}

/*

||  //   //"""""\\   | \      ||
|| //   //           ||\\     ||
||//   ||            || \\    ||
|//    ||            ||  \\   ||
|\\    ||            ||   \\  ||
||\\   ||            ||    \\ ||
|| \\   \\           ||     \\||
||  \\   \\_____ //  ||      \ |

*/

#include <bits/stdc++.h>

#define ll              long long
#define endl            '\n'
#define cd              cout << '\n';
#define ys              cout << "YES"; return;
#define no              cout << "NO"; return;
#define pii             pair<int,int>
#define IOS             ios::sync_with_stdio(0);
#define vi              vector<int>
#define vll             vector<long long int>
#define vpii            vector<pair<int,int>>
#define pb              push_back
#define in              insert
#define mp              make_pair
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define fr              first
#define sc              second
#define sz(a)           a.size()
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define buga(i,n,a)     cout << endl; for(i = 0; i < n; ++i) cout << a[i] << " "; cout << endl;
#define bugv(i,n,v)     cout << endl; for(i = 0; i < n; ++i) cout << v[i].first << " " << v[i].second << endl; cout << endl;

using namespace std;

//vector< pair <int,int> > v;
/*
cout << fixed << setprecision(12)

bool sortvector(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}

*/

void solve()
{
    ll n, m, i, c = 0, sum = 0;
    cin >> n >> m;
    ll a[n];
    for(i = 0; i < n; ++i) {
        cin >> a[i];
        sum+= a[i];
        if(sum >= m) {
            sum = a[i];
            ++c;
        }
    }
    if(c == 0) ++c;
    cout << c;
}

int main()
{
    IOS;
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
        cout << endl;
    }

    return 0;
}

#include<cstdio>
#include<iostream>
#include<memory.h>
using namespace std;
int n,m,a[105],ans,res;
int main()
{
	while(cin>>n>>m)
	{
		for(int i=0;i<n;i++)
			cin>>a[i];
		ans=0;
		for(int i=0;i<n;i++)
		{
			res=m-a[i];
			while(res>=a[i+1])
				res-=a[i++];
			ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

int main(){
    int n, m, a[101], res = 0, sum = 0;
    cin >> n >> m;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++){
        if(sum + a[i] < m)
            sum += a[i];
        else if(sum + a[i] == m){
            sum += a[i];
            res++;
            sum = 0;
        }
        else{
            res += 2;
            sum = 0;
        }
    }
    cout  << res << "\n";
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define endl "\n"
#define pb push_back
#define mp make_pair
int main()
{
        ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
		int n,k,m,ans=0,r=0,sum=0,i;
		cin>>n>>m;
		int a[n];
		k=m;
		for(i=0;i<n;i++){
			cin>>a[i];
		}
		for(i=0;i<n;i++){
			sum=sum+a[i];
			if(a[i]>=m)
			ans++;
			if(sum<m)
			continue;
			else{
				ans++;
				sum-=a[i];
			}
		}
		if(sum<m)
		ans=1;
		cout<<ans<<endl;
 return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,t,sum(0),ans(0),c(0);
    cin>>n>>m;
      while(n--)
      {
          cin>>t;
          sum=sum+t;
         if(sum==m)
         ans++;
         else if(sum>m)
         {
             ans++;
             sum=t;
         }
      }
     if(ans==0)
      cout<<"1";
      else if(sum==0)
      cout<<ans;
      else
      cout<<ans+1;

}

#include<iostream>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int arr[n+1];
    int sum=0,ans=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        sum+=arr[i];
    }
    ans=(sum/m);
    if(sum%m!=0) ans++;
    cout<<ans<<endl;
    return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int m,n,sum=0,counter=1;
    cin>>n>>m;
    int arr[n];
    for( int i=0 ; i<n ; i++)
    {
        cin >> arr[i];
    }
    for ( int i=0 ; i<n ;)
    {
        sum=0;
        while(sum<=m)
        {
            sum +=arr[i];
            i++;
        }
        counter++;

    }
    cout<<counter<<endl;

    return 0;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <cstring>

using namespace std;

#define mp make_pair
#define pp push_back
#define Sort(x) sort(x.begin(), x.end())
#define rep(i, x, y) for(int i = x; i < y; ++i)
#define Rep(i, x, y) for(int i = x; i <= y; ++i)
#define dRep(i, x, y) for(int i = x;i >= y; --i)
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long
#define all(v) v.begin(),v.end()
#define ii pair<int, int>
#define mem(x, v) memset(x, v, sizeof(x))
#define nl '\n'
#define MOD 1000000007

int main()
{
    int n, sum, size;
    int rem;
    int cur;
    int res = 0;
    while(cin >> n >> size)
    {
        cur = 0;
        res = 0;
        int temp;
        rep(i, 0, n)
        {
            cin >> temp;
            cur += temp;
            if(cur >= size)
                res++, cur %= size;
        }
        if(cur)
            res++;
        cout << res << nl;
    }

    return 0;
}

#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n,m,total=0;
    cin>>n>>m;
    vector<int>vc;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        vc.push_back(x);
    }
    int cnt=0;
    for(int i=0;i<vc.size();i++){
        total+=vc[i];
        if(i+1!=vc.size()){
            if(total==m){
                total=0;
                cnt++;
            }
            else if(total>m){
                total-=m;
                cnt++;
            }
        }
        else{
            while(1){
                if(total<=m){
                    cnt++;
                    total=0;
                    break;
                }
                else{
                    total-=m;
                    cnt++;
                }
            }
        }

    }

    cout<<cnt<<"\n";

    return 0;
}

#include<bits/stdc++.h>
#include<cmath>
using namespace std;
const int MAXN = 1000000;
long long a[MAXN], b[MAXN];
long long y ,x, z,c, t, m ,f, e, l, d, n, k;
string s[MAXN], h, v;
//set <char> k;
bool mark[MAXN];
char g, q;
int main(){
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		cin >> x;
		y += x;
	}
	if (y % m != 0)
		y = (y + m) / m;
	else
		y /= m;
	cout << y;
	return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int n,m,bus=0;
    cin>>n>>m;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    int ca=m;
   for(int i=0;i<n;i++){
    if(ca>=a[i] && i<n)
        ca-=a[i];
    else {
    ca=m;
    bus++;
    }

   }
   cout<<bus;
    return 0;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

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

    int cnt = 1;
    int pple = 0;

    for(int i = 0; i < n; i++)
    {
        if (pple + a[i] <= m)
            pple += a[i];
        else
        {
            cnt++;
            pple = a[i];
        }
    }

    cout << cnt << endl;
}

//Abdul Rais
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <fstream>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define MAX 55
using namespace std;
int n,m,a[101],sum,ans,b,i;
vector<int >v;
int main(){
    cin>>n>>m;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    for(i=0;i<n;i++){
        sum+=a[i];
        if(sum<m){
            continue;
        }
        else{
            if(sum==m){
                ans++;
                sum=0;
                continue;
            }
            else{
                v.push_back(sum-m);
                sum=0;
                ans++;
            }
        }
    }
    if(n==1)
    cout<<1;
    else
    cout<<ans+v.size();
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{

   int n,m,a[100000],k,e;
   cin>>n>>m;
   int i=1;
   e=0;
   k=m;
   for (int i=1;i<=n;i++) cin>>a[i];

   for (int i=1;i<=n;i++){
       if (a[i]<=m) m=k-a[i];
       else {
           e++;
           m=k-a[i];
       }
       cout<<m<<endl;
}cout<<e+1;}

#define _CRT_SECURE_NO_DEPRECATE
#define _SECURE_SCL 0
#pragma comment(linker, "/STACK:300000000")

#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <iomanip>
#include <iterator>
#define ll long long
#define pub push_back
#define mp make_pair
#define fst first
#define snd second
#define eps 1e-6
#define pi 3.14159265358979323846264
#define sz(c) int((c).size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define forit(it, v) for(__typeof(v.begin()) it = v.begin(); it != v.end(); ++it)
const int dx[] = { 1, 0, -1, 0 }, dy[] = { 0, -1, 0, 1 };

using namespace std;

int MAX = -2e9, MIN = 2e9;
ll int A[2000001];

int main(){
	ifstream in("input.txt");
	ofstream out("output.txt");
	/*ostream_iterator< int > output( cout, " " );
	copy( vec.begin(), vec.end(), output );*/
	int n, m, sum = 0, cnt = 0;
	cin >> n >> m;

	for (int i = 0; i < n; i++){
		int a;
		cin >> a;
		sum += a;
		if (sum <= m) continue;
		else cnt++, sum = sum % m;
	}
	if (sum == 0)
		cout << cnt;
	else cout << cnt + 1;
	return 0;
}

#include <iostream>
using namespace std;
int main()
{
    int n,a,c=0,k=0;
    cin>>n>>a;
    int*arr=new int[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
for(int i=0;i<n;i++)
{
    if((arr[i]+c)==a)
        k++;
    else if(arr[i]<a)
    {
        c+=arr[i];
    }
    else if((arr[i]+c)>a)
    {
        k+=i+1;
        c=0;
    }
}
cout<<k;
  delete[]arr;
    return 0;
}

/*
 *  Created on: 27 / 8 / 2020
 *  Author:     Eslam Waheed
 */

#define _CRT_SECURE_NO_WARNINGS
//#define __USE_MINGW_ANSI_STDIO

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

#define Eslam__Waheed ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

#define ll   long long
#define ull  unsigned ll
#define ld   long double

#define all(c)   c.begin(), c.end()
#define rall(c)  c.rbegin(), c.rend()
#define stp(n)   cout << fixed << setprecision(n);
#define iq(v)    v.resize(unique(v.begin(),v.end())-v.begin())
#define sz(s)    s.size()
#define endl     '\n'

//ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }

//const ld PI = acos(-1);
//const ll mod = 1e9 + 7;
//const ld EPS = 1e-8;
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
int main()
{
	//stp(0)
	Eslam__Waheed;
	int n, m; cin >> n >> m;
	vector<int>v(n);
	for (auto& it : v)
	{
		cin >> it;
	}
	int ans = 0, sum = 0;
	bool f = 1;
	for (int i = 0; i < n; i++)
	{
		if ((sum + v[i]) == m)
		{
			ans++;
			sum = 0;
			f = 0;
		}
		else
		if ((sum + v[i]) > m)
		{
			ans++;
			sum = v[i];
			f = 0;
		}
		if (f)
			sum += v[i];

		f = 1;
	}
	cout << ans;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,sum=0,p=0,l=0,a=0;
	cin>>n>>m;
	int num[n];
	int y=n;
	int size[n];
	int arr[n][n];
	for(int i=0;i<n;i++){
		cin>>num[i];

	}
	if(n==1){
		cout<<"1";
	}
	else{

	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
		       arr[i][j]=0;
		  }
	}

			for(int i=0;i<n;i++){
		for(int j=a;j<n;j++){
			arr[i][j]+=num[j];
			arr[i][j+1]+=arr[i][j];
		}
		a=i+1;
		arr[i+1][0]=0;
	}
		for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(arr[i][j]==m){
				l++;
				j=n;
			}
			if(arr[i][j]>m){
				l++;
				j=n;
			}

	}
}

	cout<<l<<endl;

	}
}

// In the Name Of God

#include <iostream>
#include <fstream>

#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <istream>
#include <queue>
#include <cmath>
#include <stack>

#define inf (int)(~0u/2)
#define ll_inf (long long)1ll << 62
#define int long long
#define float double
#define eps (1e-8)
#define for2(i, a, b) for ( int (i) = (a); (i)<(b); (i)++ )
#define mp make_pair
#define f1 first
#define f2 second
#define pb push_back
#define pii pair<int,int>
#define vpii vector <pii>
#define vi vector<int>
#define sz(a) (int) a.size( )
#define fillArr(n, a) for2(i, 0, n) cin >> a[i];
#define print(a) cout << #a << endl;
#define umax(a,b) a = max ( a, b )
#define umin(a,b) a = min ( a, b )
#define all(k) k.begin ( ), k.end( )
#define rall(k) k.rbegin ( ), k.rend( )
#define ll long long
#define clean(k) memset( k, 0, sizeof(k) )
using namespace std;

int dp[12000][300];
const int mod = 1234567;
int a[2000];

void main ( ){
    int n, m;
    cin >> n >> m;
    for2 ( i, 0, n ){
        cin >> a[i];
    }
    int num = 0;
    int ind = 0;
    for ( ; ind < n; ){
        int k = 0;
        while ( ind < n ){
            if ( k + a[ind] <= m ){
                k += a[ind];
                ind++;
            }
            else{
                a[ind] -= ( m - k );
                k = m;
                break;
            }
        }
        num++;
    }
    cout << num << endl;
}

#include<iostream>
using namespace std;
int main(){
int n,m,a[105],mc=0,sum=0,i=0,j;
cin>>n>>m;
for( j=0;j<n;j++)cin>>a[j];
a[n]=999;

if(n==1)cout<<1<<endl;else{

while(i<n){
	sum+=a[i];
	if(sum+a[i+1]<=m){i++;cout<<"----"<<i;}else
		if(sum==m){mc++;i++;sum=0;cout<<">>>"<<i;}
	else{ mc++;sum=0;i++;cout<<"LLLLLL"<<i;}}

cout<<mc<<endl;}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m, x, ans=1, bus=0;
	cin >> n >> m;
	for(int i=0;i<n;i++){
		cin >> x;
		if(bus+x <= m){
			bus += x;
		}else{
			ans++;
		}
	}
	cout << ans;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,m,a,x=0,y;
    double b;
    cin >> n >> m;
    for ( int i=0 ; i<n ; i++ )
    {
        cin >> a;
        x+=a;
    }
    y=x/m;
    b=(double)(x*1.0/m*1.0);
    if (abs(b-y)>0)cout << y+1 << endl;
    else cout << y << endl;
    return 0;
}

#include <iostream>
using namespace std;
int main(){
	int n,m;
	cin>>n,m;
	int a[n];
	int i;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	int count=0,k=0,j=0;
	while(k<n){
		int t;
		t=a[k];
		if(t==m){
			count++;
		}
		else{
			while(t<m){
				t+=a[k+1];
				j++;
			}
			count++;
			if(t=m){
				k+=j;
			}
			else{
				k++;
			}
			j=0;
		}
	}
	cout<<count-1;
}

#include <iostream>
using namespace std;
int main()
{
    int N, m;
    cin >> N >> m;
    int avt = 0;
    int * a = new int [N];
    for (int i = 0; i < N; i++)
        cin >> a[i];
    int pred = 0;
    for (int i = 0; i < N; i++)
    {
        pred += a[i];
        if (pred >= m)
        {
            avt++;
            if (a[i] == m)
                avt++;
            else pred = a[i];
            pred = 0;
        }
    }
    if (pred)
        avt++;
    cout << avt;
}

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

int main(){

    int n,m;
    cin>>n>>m;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    int total = 0,s = 0;
    for(int i=0;i<n;i++){
        total += a[i];
        if(total == m){
            total = 0;
            s++;
        }
        else if(total > m){
            total = 0;
            i--;
            s++;
        }
    }

    s == 0 ? cout<<1 : cout<<s;
    return 0;
}

#include<bits/stdc++.h>
#include<cmath>
using namespace std;
const int MAXN = 1000000;
long long a[MAXN], b[MAXN];
long long y ,x, z,c, t, m ,f, e, l, d, n, k;
string s[MAXN], h, v;
//set <char> k;
bool mark[MAXN];
char g, q;
int main(){
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
	{
		if (y + a[i] >= m)
		{
			y = 0;
			x++;
		}
		y += a[i];
	}
	if (x == 0 && y <= m)
	{
		x++;
	}
	cout << x;
	return 0;
}

#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<iostream>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<ctime>
#include<list>
#include<deque>
#include<bitset>
#include<string>
#include<string.h>
#define in freopen("input.txt","r",stdin)
#define out freopen("output.txt","w",stdout)
using namespace std;
int main()
{
int cnt, a[1005],n,m,i,d=0,b=0,c=0;
cin>>n>>m;
for(i=1;i<=n;i++){
  cin>>a[i];
c+=a[i];
}
if(c<=m){cout<<1<<endl; return 0;}
for(i=1;i<n;i++){
  if( m-a[i] < a[i+1] ){
     d++;
  }
  else if( m-a[i] >= a[i+1] ){
    d++;
    a[i]=a[i+2];
  }
}
cout<<d<<endl;
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std ;
int a[105],vis[105] ;
int cmp(int a,int b)
{
    return a>b ;
}
int main()
{
    int n,m ;
    scanf("%d%d",&n,&m) ;
    for(int i=0 ;i<n ;i++)
    {
        scanf("%d",&a[i]) ;
    }
    int ans=0 ;
    sort(a,a+n,cmp) ;
    for(int i=0 ;i<n ;i++)
    {
        int res ;
        if(!vis[i]){
            ans++ ;
            res=a[i] ;
        }
        else continue ;
        for(int j=i+1 ;j<n ;j++)
        {
            if(!vis[j] && res+a[j]<=m)
            {
                a[j]=0 ;
                res+=a[j] ;
                vis[j]=1 ;
            }
        }
    }
    printf("%d\n",ans) ;
    return 0 ;
}

#include<bits/stdc++.h>
#include<algorithm>
#define endl "\n"
#define ll long long int
#define ull unsigned long long int
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
int n,m;
cin>>n>>m;
int a[n]={0},vst[n]={0};
int bus=0;
for(int i=0;i<n;i++)
    cin>>a[i];
for(int i=0;i<n;i++)
{
    int sum=a[i];
    for(int j=i+1;j<n;j++)
    {
        vst[i]=1;
        if(a[i]==m)
        {
            bus++;
            break;
        }
        else if(sum+a[j]<=m)
            {
            vst[j]=1;
            sum+=a[j];
            }
        else
        {
            i=j-1;
            bus++;
            break;
        }
        if(sum==m)
        {
            i=j;
            bus++;
            break;
        }
    }
    if(i==n-1&&sum!=0)
            bus++;
    if(vst[i]==0)
       {
        bus++;
       }
}
cout<<bus;
return 0;
}

//by maximumSHOT

#define _USE_MATH_DEFINES

#include <iostream>
#include <cmath>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <time.h>
#include <clocale>
#include <fstream>
//#include <conio.h>

using namespace std;

#define forx(i,n) for(int i(0);i < n;i++)
#define vec vector

typedef long L;
typedef long long LL;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<double> vdouble;
typedef vector<vector<double>> vvdouble;
typedef vec<bool> vbool;
typedef vec<vec<bool>> vvbool;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<double,int> pdi;
typedef pair<int,double> pid;
typedef unsigned long long ull;
typedef unsigned int ui;
const int inf = 1000 * 1000 * 1000;
const LL inf64 = LL(inf) * inf;
void show(LL a){cout << a--;}
void zero(int a){a = 0;}

bool solve()
{
    ios_base::sync_with_stdio(0);

    int n,m,x,count = 0;

    cin >> n >> m;

    if(n == 1)
    {
        cin >> x;

        cout << "1\n";return true;
    }

    vint a;

    int tmp = m,sum = 0;

    for(int i(0);i < n;i++)
    {
        cin >> x;

        a.push_back(x);
    }

    for(int i(0);i < n-1;i++)
    {
        sum = a[i];
        while((i+1 < n) && sum + a[i+1] <= m)
        {
            sum += a[i+1];
            i++;
        }
        count++;
    }

    cout << count << '\n';

    //_getch();
    return true;
}

int main(int argc,char **argv)
{
    //while(solve());
    solve();

    return 0;
}

# include <iostream>
using namespace std;
int main()
{
	int capacity=0;
	int q=0;
	int a=0;
	int result=0;
	int counter=0;
	//cout<<"q";
	cin>>q;
	//cout<<"capacity";
	cin>>capacity;
	for(int i=0;i<q;i++)
	{
			//cout<<"n";
			cin>>a;
			//counter=counter+a;
			if(a==capacity)
			{
				if(counter>0 && counter<=capacity)
				{
					result+=2;
					counter=0;
				}else result++;
			}
			else //if(a<=capacity)
			{
				counter+=a;
				if(counter==capacity)
				{
				result++;
				counter=0;
				}
				else if(counter>capacity)
				{
				result++;
				counter=a;
				}
			}
			if(counter!=0)result++;
	}
	cout<<result;
}

#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <ctype.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <stdio.h>
#define File_in(input) freopen(input, "r", stdin)
#define File_out(output) freopen(output, "w", stdout)
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int,int> point;
const int ms = 1e5+10;
const int mod = 1000000007;
const ll inf = 2147483645;

bool cmp (point p1, point p2) {
  return p1.first > p2.first;
}

int main () {
    //File_in("input.txt"); File_out("output.txt");
    ios_base::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    int a[111] = {0};
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    int t = 0;
    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
        ans+=(a[i]/m);
        a[i+1] += a[i] % m;
    }
    ans+=(a[n-1]/m);
    if (a[n-1] % m > 0)
        ans++;
    cout << ans << endl;
}

//with the name of Allah
#include <bits/stdc++.h>
#define in freopen("input.txt","r",stdin);
#define out freopen("output.txt","w", stdout);
using namespace std;
int n[105] , cnt=0 , sm , k , l , ans=1 ;
main()
{
    cin>>k>>l;
    for(int i=1; i<=k; i++)
    {
        cin>>n[i];
    }
    while(ans!=k)
    {
        int sm=0;
        for(int i=ans+1; i<=k; i++)
        {
           if(sm+n[i]<=l)
           { sm+=i;  ans=i; }
           else
           break;
        }
        cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

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

int main(){
int n,m,numbers_bus=0,full=0;
cin>>n>>m;
int groups[100];
for (int i=0;i<n;i++){
	cin>>groups[i];
}
for (int i=0;i<n;i++){
	if (groups[i]==m){
		numbers_bus++;
		if (full!=0){
			numbers_bus++;
			full=0;
		}
	}else{
		full+=groups[i];
		if (full==m){
			full=0;
			numbers_bus++;
		}else if (full>m){
			full=0;
			numbers_bus+=2;
		}

	}
}
cout<<numbers_bus;
return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int n, m;
    cin>>n>>m;
    //char a[n][m];

    for(int i=0; i<n; i++)
    {
        int ii=i;
        for(int j=0; j<m; j++)
        {
            ii++;
            char x;
            cin>>x;
            if(x=='.')
            {
                if(ii%2==0)
                    cout<<'W';
                else
                    cout<<'B';
            }
            else
                cout<<x;
        }
        cout<<endl;
    }

    return 0;
}

//lotfan sol nabash :D
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 1e5+10;
main(){
	int n , m; cin >> n >> m;
	int a[n+10]; memset(a,false,sizeof a);
	for(int i = 1;i <= n;i++) cin >> a[i];
	int k = m;
	int ans = 0;
	for(int i = 1;i <= n;i++){
		if(a[i] < m){
			k = m;
			ans++;
		}
		k -= a[i];
	}
	cout << ans << endl;
}

#include <iostream>
#include <string>
using namespace std;
void main()
{
    int n, m, a[101],i,sum=0,temp=0,k=0;
    cin >> n >> m;
    for (i = 0; i < n; i++)
    {
        cin >> a[i];
        k += a[i];
    }
    for (i = 0; i < n; i++)
    {
        if (m >= k)
        {
            cout << "1" << endl;
            return;

        }
        if (m > temp + a[i])
        {
            m -= a[i];

            temp = 0;
        }
        else
        {
            sum++;
            temp = a[i];
        }
    }
    cout << sum << endl;
}

#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define endl "\n"
#define pb push_back
#define mp make_pair
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
		int n,k,m,ans=0,r=0,sum=0,i,flag=0;
		cin>>n>>m;
		int a[n];
		for(i=0;i<n;i++)
		cin>>a[i];
	    for(i=0;i<n;i++){
	    	 //if(a[i]<m)
	    	 sum+=a[i];
	    	 if(sum<m)
	    	 continue;
	    	 if(sum==m){
	    	 ans++;
	    	 sum=0;}
	    	 if(sum>m){
	    	 	sum=0;
	    	 	ans=ans+1+a[i]/m+((a[i]%m)!=0);
	    	 //	cout<<a[i];
	    	 }
	    	// if(a[i]>=m){
	    	 //ans=ans+a[i]/m+((a[i]%m)!=0);}
	    }

	    if(ans==0)
	    cout<<"1"<<endl;
	    else
	    cout<<ans<<endl;

 return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#define MAX 107
using namespace std;
typedef long long ll;
int a[MAX];
int main()
{
	int n,m;
	while(~scanf("%d%d",&n,&m))
	{
		int cur = 0;
		int cnt = 0;
		for(int i = 0;i < n;i++)
		{
			scanf("%d",a+i);
			cur += a[i];
		}
		cnt = cur/m;
		if(cnt % m != 0)
			cnt++;
		printf("%d\n",cnt);
	}
	return 0;
}

#include <map>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std ;

#define sz size()
#define eps (1e-9)
#define inf (1 << 28)
#define pb push_back
#define del( a , b ) memset( a , b , sizeof ( a ) )

int main ()
{
    int n , m , i , temp , sum=0 , ans = 1 ;
    vector <int> vi ;
    scanf ("%d %d",&n,&m);
    for ( i=0 ; i<n ; i++ )
    {
        scanf ("%d",&temp);
        vi.pb(temp);
    }
    for ( i=0 ; i<vi.size() ; i++ )
    {
        if(!vi[i])
        continue;

        if(sum==m){
            ans++;
            sum=0;
        }
        if(sum+vi[i]<m){
            sum += vi[i];
        }else if ( sum+vi[i] == m )
        {
            ans ++ ;
            sum=0;
        }else if ( sum+vi[i] > m )
        {
            for(int j=i;j<n;j++){
                if(sum+vi[j]<m){
                    sum+=vi[j];
                    vi[j] = 0;
                }else if(sum+vi[j]==m){
                    sum = 0;
                    vi[j] = 0;
                    break;
                }else{
                    continue;
                }
            }
            if(sum==0){
                sum+=vi[i];
                ans++;
            }else{
                sum = 0;
                ans++;
                sum+=vi[i];
            }
        }
        /*
        if ( sum > 0 && i==vi.size() - 1 )
        {
            if ( vi[vi.size()-1] <= m )
                ans ++ ;
            else
            {
                ans += ( vi[vi.size()-1]/m );
                ans += vi[vi.size()-1]%m ;
            }
        }
        */
    }
    if(sum==0){
        ans-=1;
    }
    cout << ans << endl ;
    return 0;
}

#include <iostream>
#include <stdlib.h>
#include <vector>
using namespace std;

int main ()
{
	int n, m;
	vector<int> a;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	int num = 0;
	int currentSize = m;
	while ( !a.empty() )
	{
		for (auto it = a.begin(); it != a.end();)
		{
			if (*it <= currentSize)
			{
				currentSize -= *it;
				it = a.erase (it);
			}
			else    it ++;
			if (currentSize == 0)    break;
		}
	num ++;
    currentSize = m;
	}

	cout << num << endl;
    return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int n;
    int m;
    int a[100];
    int S=0;
    int B = 0;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        S = S + a[i];
    if (n>m)
        B = (S / m) + 1;
    else
        B = (S / m);

    cout << B << endl;

}