from math import factorial
def choose(n, c):
    return factorial(n) / factorial(c) / factorial(n - c)

tab = {}
def amount(y, n, t):
    if n == 1 and t == 0:
        return 1
    if n > 6 * t + 1 or t == 0 or n <= 0 or y >= 4:
        return 0
    if (y, n, t) not in tab:
        res = 0
        for top in xrange(y + 1, 5):
            for bottom in xrange(1, top):
                for i in xrange(top - y):
                    for j in xrange(top - bottom):
                        res += amount(bottom, n - (i + j + 3) + 1, t - 1) * choose(top - y - 1, i) * choose(top - bottom - 1, j)
        tab[(y, n, t)] = res
    return tab[(y, n, t)]

n, t = map(int, raw_input().split())
res = 0
for i in xrange(1, 4):
    res += amount(i, n, t)
print res

from itertools import permutations

n, t = map(int, raw_input().split())
dp = [[[0] * 4 for i in xrange(t * 2)] for j in xrange(n)]

for i in xrange(4):
    dp[1][0][i] = i

for i in xrange(1, n - 1):
    for j in xrange(t * 2):
        for p, q in permutations(xrange(4), 2):
            fr = dp[i][j][p]
            if j & 1:
                if p > q:
                    dp[i + 1][j][q] += fr
                elif j + 1 < t * 2:
                    dp[i + 1][j + 1][q] += fr
            else:
                if p < q:
                    dp[i + 1][j][q] += fr
                elif j + 1 < t * 2:
                    dp[i + 1][j + 1][q] += fr

print sum(dp[n - 1][t * 2 - 1][i] for i in xrange(4))

import sys

points, peaks = (int(x) for x in sys.stdin.readline().split())
mem = {}

def hump(n_points, n_peaks, n_humps, prev, slope, sol=""):
    if n_peaks < 0 or n_humps < 0:
        return 0
    if n_points == 0 and n_peaks == 0 and n_humps == 0:
        #print(sol, n_peaks)
        return 1
    if n_points == 0:
        return 0
    if (n_points, n_peaks, n_humps, prev, slope) in mem:
        return mem[(n_points, n_peaks, n_humps, prev, slope)]

    r = 0
    for i in range(1, 5):
        if i == prev:
            continue
        new_n_points = n_points-1
        new_n_peaks = n_peaks-1 if slope > 0 and i < prev and n_points+2 <= points else n_peaks
        new_n_humps = n_humps-1 if slope < 0 and i > prev and n_points+2 <= points else n_humps
        new_prev, new_slope = i, -1 if i-prev < 0 else 1
        r += hump(new_n_points, new_n_peaks, new_n_humps, new_prev, new_slope)
    mem[(n_points, n_peaks, n_humps, prev, slope)] = r
    return r

print(hump(points, peaks, peaks-1, -1, 0))

n, t = [int(x) for x in raw_input().strip().split()]
c = []
for xn in xrange(n):
    c.append([])
    for xt in xrange(t + 1):
        c[xn].append([])
        for xh in xrange(4):
            c[xn][xt].append([0] * 2)
for xh in xrange(4):
    c[1][0][xh][1] = xh
for xn in xrange(2, n):
    for xt in xrange(t + 1):
        for xh in xrange(4):
            for p in xrange(xh):
                c[xn][xt][xh][1] += c[xn - 1][xt][p][0]
                c[xn][xt][xh][1] += c[xn - 1][xt][p][1]
            for p in xrange(xh + 1, 4):
                c[xn][xt][xh][0] += c[xn - 1][xt][p][0]
                if xt > 0: c[xn][xt][xh][0] += c[xn - 1][xt - 1][p][1]
s = 0
for h in xrange(4):
    s += c[n - 1][t][h][0]
print s

import sys
from array import array  # noqa: F401

def input():
    return sys.stdin.buffer.readline().decode('utf-8')

n, t = map(int, input().split())

dp = [[[0] * 5 for _ in range(2 * t + 1)] for _ in range(n)]
dp[0][0] = [0] + [1] * 4

for i in range(n - 1):
    for j in range(min(2 * t, i + 1)):
        if (j & 1) == 0:
            for k in range(1, 4):
                for l in range(k + 1, 5):
                    # //
                    dp[i + 1][j][l] += dp[i][j][k]
                    # /\
                    dp[i + 1][j + 1][l] += dp[i][j][k]
        else:
            for k in range(4, 1, -1):
                for l in range(k - 1, 0, -1):
                    # \\
                    dp[i + 1][j][l] += dp[i][j][k]
                    # \/
                    dp[i + 1][j + 1][l] += dp[i][j][k]

print(sum(dp[-1][2 * t]))

__author__ = 'Darren'

def solve():

    def find_ways(t, n, h):
        if t == breaks and n == total:
            return 1
        if t > breaks or n == total:
            return 0
        if (t, n, h) not in dp:
            result = 0
            if t % 2 == 0:
                for i in range(h+1, 5):
                    result += find_ways(t, n+1, i)
                for i in range(1, h):
                    result += find_ways(t+1, n+1, i)
            else:
                for i in range(h+1, 5):
                    result += find_ways(t+1, n+1, i)
                for i in range(1, h):
                    result += find_ways(t, n+1, i)
            dp[(t, n, h)] = result
        return dp[(t, n, h)]

    total, humps = map(int, input().split())
    breaks = 2 * humps - 1
    dp = {}
    ans = 0
    for i in range(2, 5):
        ans += (i - 1) * find_ways(0, 2, i)
    print(ans)

if __name__ == '__main__':
    solve()

from math import factorial
def choose(n, c):
    return factorial(n) / factorial(c) / factorial(n - c)

tab = {}
#number of ways to draw t humps with n points, in which the 1st point's y-coordinate is y
def amount(y, n, t):
    #special case where t is 0 and n is 1
    #the reason we don't test for n == t == 0 is in the next recursion,
    #we start with bottom point, so it is repeated and there is at least 1 point
    if n == 1 and t == 0:
        return 1
    if n > 6 * t + 1 or t == 0 or n <= 0 or y >= 4:
        return 0
    if (y, n, t) not in tab:
        res = 0
        for top in xrange(y + 1, 5):
            for bottom in xrange(1, top):
                for i in xrange(top - y):
                    for j in xrange(top - bottom):
                        res += amount(bottom, n - (i + j + 3) + 1, t - 1) * choose(top - y - 1, i) * choose(top - bottom - 1, j)
        tab[(y, n, t)] = res
    return tab[(y, n, t)]

n, t = map(int, raw_input().split())
res = 0
for i in xrange(1, 4):
    res += amount(i, n, t)
print res

from math import factorial
def choose(n, c):
    return factorial(n) / factorial(c) / factorial(n - c)

tab = {}
def amount(y, n, t):
    if n == t == 0:
        return 1
    if n > 6 * t + 1 or t == 0 or n < 0 or y >= 4:
        return 0
    if (y, n, t) not in tab:
        res = 0
        for top in xrange(y + 1, 5):
            for bottom in xrange(1, top):
                for i in xrange(top - y):
                    for j in xrange(top - bottom):
                        res += amount(bottom + 1, n - (i + j + 3), t - 1) * choose(top - y - 1, i) * choose(top - bottom - 1, j)
        tab[(y, n, t)] = res
    return tab[(y, n, t)]

n, t = map(int, raw_input().split())
res = 0
for i in xrange(1, 4):
    res += amount(i, n, t)
print res


#!/usr/bin/python
N,M=raw_input().split(' ')
N=int(N)
M=int(M)
a=map(int, raw_input().split())
a.append(0)
ans=0
i=0
while(i<N):
#for i in xrange(N):
	pres=M
	j=i
	while(pres>0 and j<N):
		if(a[j]<=pres):
			pres=pres-a[j]
		else:
		 	break
		j=j+1
	if(j<N):
		i=j
	else:
	 	i=N
#	print i,j
	ans+=1
print ans

n,k=map(int,input().split())
list1=list(map(int,input().split()))[:n]
sum1=0
c=0
for i in list1:
    sum1=sum1+i
    if sum1>k:
        sum1=i+0
        c=c+1
print(c+1)

r=lambda:map(int, raw_input().split())
n,k=r()
t=r()
b=0
c=0
for e in t:
    if b + e > k:
        b = 0
        c+=1
    b+=e
if b: c+=1
print c

import sys
n,m = [int(x) for x in sys.stdin.readline().split(' ')]
S = [int(x) for x in sys.stdin.readline().split(' ')]

i = 0
num_buses = 1;
num_in_bus = 0;
while i < n:
	if S[i] + num_in_bus > m:
		num_buses += 1
		num_in_bus = 0
	else:
		num_in_bus += S[i]
		i += 1
print num_buses

from functools import reduce
R = lambda: map(int, input().split())
F = lambda x, y: (x[0] + 1, y[1]) if x[1] + y[1] > m else (x[0], x[1] + y[1])
n, m = R()
s = reduce(F, zip([0] * n, R()), (1, 0))
print(s[0])

n, m = map(int,input().split())
group = list(map(int,input().split()))

b = 0

tot = 0
for i in range(n):
    tot += group[i]
    if tot > m :
        b += 1
        tot = group[i]
    elif tot == m :
        b += 1
        tot = 0
    if i == n-1 and tot != 0 :
        b += 1
print(b)

n, m = map(int,input().split())
a = list(map(int,input().split()))
b = 0
turn = 0
for i in range(n):
    turn += a[i]
    if turn > m :
        b += 1
        turn = a[i]
    elif turn == m:
        b += 1
        turn = 0
if turn > 0:
    b += 1
if n == 1:
    b = 1

print(b)

n, m = map(int, input().split())
groups = [int(c) for c in input().split()]

ans = 1
cap = m

for g in groups:
    if g <= cap:
        cap -= g
    else:
        ans += 1
        cap = m - g

print(ans)

def turn(lst, m):
    count, i = 0, 0
    while i < len(lst):
        z = m
        while z >= lst[i]:
            z -= lst[i]
            i += 1
            if i >= len(lst):
                break
        count += 1
    return count

N, M = [int(j) for j in input().split()]
b = [int(x) for x in input().split()]
print(turn(b, M))

n, m = map(int, input().split())
a = list(map(int, input().split()))
i, ans = 0, 0

while i < n:
    ans += 1
    cap = a[i]
    while i < n - 1 and cap + a[i+1] <= m:
        i += 1
        cap += a[i]
    i += 1

print(ans)

n, m = map(int, input().split())
l = list(int(i) for i in input().split())
s = 0
res = 1
for i in l:
    if i + s <= m:
        s += i
    else:
        res += 1
        s = i
print(res)

'''input
3 4
1 2 1
'''
n, m = map(int, input().split())
a = list(map(int, input().split()))
t = 0
while a:
	s = a.pop(0)
	while a and s + a[0] <= m:
		s += a.pop(0)
	t += 1
print(t)

'''
ID: essi
LANG: PYTHON3
TASK: self-contest.py
'''
n, m = map(int,input().split())
a = list(map(int,input().split()))
res = 1
su = 0
for i in range(n):
    su+= a[i]
    if su > m:
        res+=1
        su = a[i]
print(res)

#!/usr/bin/python3
from sys import exit
n,t = input().split()
n = int(n)
t = int(t)
test_case = input()
a = []
#matrix = [ 0 for x in range(101)]
for w in test_case.split():
    r = int(w)
    a.append(r)
#a.sort()
ans = 0
k = 0
for i in range (n):
    if( (k + a[i]) > t):
        ans += 1
        k = a[i]
    else:
        k += a[i]
print(ans+1)
exit()

n, m = map(int, input().split())
a = [int(x) for x in input().split()]
out = 0

while (a != []):
    c, a2 = m, a.copy()
    for i in a2:
        if (i <= c):
            c -= i
            a.remove(i)
        else:
            break
    out += 1
print(out)

import sys
import math

n, m = [int(x) for x in (sys.stdin.readline()).split()]
ai = [int(x) for x in (sys.stdin.readline()).split()]

f = 0
result = 0
for c in ai:
    if(f + c < m):
        f += c
    elif(f + c == m):
        result += 1
        f = 0
    else:
        f = c
        result += 1

if(f > 0):
    result += 1

print(result)

def main():
    l = input()
    parts = l.split(" ")
    n = int(parts[0])
    m = int(parts[1])
    arr = []
    l = input()
    for a in l.split(" "):
        arr.append(int(a))
    i = 0
    res = 0
    while True:
        s = 0
        while i < n and s+arr[i]<= m:
            s += arr[i]
            i += 1
        res += 1
        if i == n:
            break
    print(str(res))
if __name__ == '__main__':
    main()

t = input().split()
n = int(t[0])
m = int(t[1])
del t
t = [int(x) for x in input().split()]
'''
slon = t.count(m)
if slon != 0:
    t.remove(m)
n = len(t)
'''
slon = 0
temp = 0
for i in range(n):
    temp = t[i]
    t[i] = 0
    for j in range(n):
        if temp + t[j] <= m:
            temp += t[j]
            t[j] = 0
        else:
            break
    if temp != 0:
        slon += 1
    #print(t)
print(slon)
'''
    if temp[i] > m:
        temp[i + 1] += (temp[i] - m)
        slon += 1
    elif temp[i] < m:
        temp[i + 1] += temp[i]
    else:
        slon += 1
slon += (temp[n - 1] // m) + (0 if temp[n - 1] % m == 0 else 1)
print(slon)
    '''

a,b=map(int,input().split())
c=list(map(int,input().split()))
d=0
e=b
for i in c:
    if e>=i:
        e-=i
    else:
        e=b-i
        d+=1
print(d+1)

import sys
size, maxPassangers = map(int, input().split())

array = list(map(int, input().split()))
counter = 0

if size == 1:
    print("1")
    sys.exit()

buffer = 0
for i in range(size):
    if buffer + array[i] <= maxPassangers:
        buffer += array[i]
    else:
        buffer = array[i]
        counter += 1

print(counter+1)

n,m=map(int,input().split())
l=list(map(int,input().split()))
count=0
sum=0
i=0
while(i<n):
    sum=sum+l[i]
    if(sum==m):
        sum=0
        count=count+1
        i=i+1
    elif(sum>m):
        sum=0
        count=count+1
    else:
        i=i+1
if(sum<m and sum>0):
        count=count+1
        i=i+1
print(count)

l=list(map(int,input().split(" ")))
n=l[0]
m=l[1]
l=list(map(int,input().split(" ")))
i=0
s=0
cnt=0
if(n==1 and l[0]<=m):
  print("1")
else:
  while(i<n):
    s=s+l[i]
    #print(i,s,cnt)
    if(s<m):
      i+=1
    elif(s==m):
      s=0
      cnt+=1
      i+=1
    else:
      s=0
      cnt+=1
  if(s>0):
    cnt+=1
  print(cnt)

n,m = map(int, input().split())
l = list(map(int, input().split()))

people = 0
buses = 1
for i in range(n):
    if people + l[i] <= m:
        people += l[i]
    else:
        buses += 1
        people = l[i]
print(buses)

a=0
i=0
b=0
z=list(map(int,input().split()))
x=list(map(int,input().split()))
while 1 :
   a+=x[i]
  # print('a=',a)
   if a>z[1]:
       b+=1
     #  print('b=',b)
       a=0
   else:
       i+=1

    #   print('i=',i)
   if i==len(x):
       break
print(b+1)

import math
n, m = map(int, input().split())

a = list(map(int, input().split()))

res = 1
pep = 0

for i in range(n):
    if pep + a[i] <= m:
        pep += a[i]
    else:
        res += 1
        pep = a[i]

print(res)

n, m = map(int, input().split())
a = [int(i) for i in input().split()]
cnt = 0
s = 0
for i in range(n):
    s += a[i]
    if s > m:
        cnt += 1
        s = a[i]
print(cnt + 1)

from sys import stdin
n, m = map(int, stdin.readline().split())
a = list(map(int, input().split()))
s = k = 0
for i in a:
    k += i
    if k > m: s, k = s + 1, i
print(s + int(k > 0))

n,m=map(int,input().split())
a=list(map(int,input().split()))

first=0;
last=n-1;
res=0;
while (first<=last):
    k=m;
    while (k>=a[first] and first<=last):
        k-=a[first];
        first+=1;
        if (first>last): break;
    res+=1;

print(res)

x=input()
x=x.split()
y=input()
y=y.split()
bus=0
i=0
empty=int(x[1])
for i in range(int(x[0])):
  if int(y[i])== int(x[1]):
    bus=bus+1
    if empty<int(x[1]):
      empty=int(x[1])
      bus=bus+1
  elif int(y[i])< empty :
    empty=empty-int(y[i])
    if i==int(x[0])-1:
      bus=bus+1
  elif int(y[i])==empty:
    empty=int(x[1])
    bus=bus+1
  elif int(y[i])>empty:
    bus=bus+1
    empty=int(x[1])
    if int(y[i])== empty :

      bus=bus+1
    elif int(y[i])< empty and i==int(x[0])-1:
      bus=bus+1
    else:
      empty=empty-int(y[i])
print(bus)

n,m = map(int,raw_input().split())
A = map(int,raw_input().split())
ans = 0;
r = 0;
for x in A:
    if r < x:
        r = m - x;
        ans += 1;
    else:
        r -= x;

print ans;

# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""
#import sys

#def pow_mod(base, exp):
#   if exp == 0:
#      return 1
#   elif exp == 1:
#      return base
#   elif (exp & 1) != 0:
#       return base * pow_mod(base * base, exp // 2)
#   else:
#       return pow_mod(base * base, exp // 2)

n, m = map(int, input().split())
a = ([int(z) for z in input().split()])
o = 0
i = 0
s = 0
while(i<n):
    s = s + a[i]
    if s>m:
        s = 0
        o = o + 1
    else:
        if i==n-1:
            o = o + 1
        i = i + 1
print(o)

#sys.stdout.flush()
#print ('', flush=True)

n,m = list(map(int, input().split(" ")))
x = list(map(int, input().split(" ")))
count,a=0,0
for i in range(n):
    if x[i]+a<=m:
        a+=x[i]
    else:
        count+=1
        a=x[i]
print(count+1)

import math
import itertools
import collections

def getdict(n):
    d = {}
    if type(n) is list or type(n) is str:
        for i in n:
            if i in d:
                d[i] += 1
            else:
                d[i] = 1
    else:
        for i in range(n):
            t = ii()
            if t in d:
                d[t] += 1
            else:
                d[t] = 1
    return d
def cdiv(n, k): return n // k + (n % k != 0)
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(map(int, input().split()))
def lcm(a, b): return abs(a*b) // math.gcd(a, b)
def wr(arr): return ' '.join(map(str, arr))
def revn(n): return int(str(n)[::-1])
def prime(n):
    if n == 2:
        return True
    if n % 2 == 0 or n <= 1:
        return False
    sqr = int(math.sqrt(n)) + 1
    for d in range(3, sqr, 2):
        if n % d == 0:
            return False
    return True

n, m = mi()
a = li()
i = ans = 0
while i < n:
    t = 0
    while t <= m and i < n:
        if t + a[i] <= m:
            t += a[i]
            i += 1
        else:
            break
    ans += 1
print(ans)

n,m=map(int,input().split())
l=[int(i) for i in input().split()]
i=0
sm=0
cnt=1
while i<n:
    sm+=l[i]
    if sm>m:
        cnt+=1
        sm=l[i]
    i+=1
print(cnt)

n,m=map(int,input().split())
L=list(map(int,input().split()))
cnt=0
cur=m
for a in L:
    if cur>=a:
        cur-=a
    else:
        cur=m-a
        cnt+=1
print(cnt+1)

'''
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
cnt = 0
s = 0
for i in range(n):
    s += a[i]
    if s > m:
        cnt += 1
        s = a[i]
print(cnt + 1)
'''

n , m = map(int, input().split())
mylist = list(map(int,input().split()))
index = 0
count = 1
bus_stop = m
while index < n :
    if bus_stop - mylist[index] >= 0:
        bus_stop -= mylist[index]
        index += 1
    else:
        bus_stop = m
        count += 1
print(count)

n, m = map(int,input().split())

u = list(map(int,input().split()))
sum=0
f=0
for k in range(n):
    if sum+u[k]<=m:
        sum+=u[k]
    else:
        f+=1
        sum=u[k]
if sum>0:
    f+=1

print(f)

counter = 1
summ = 0
teamnum, bushold = map(int, input().split())
teamlist = [int(h) for h in input().split()]
# print(ceil(sum(teamlist)/bushold))
for i in teamlist:
    if summ+i > bushold:
        counter += 1
        summ = 0
    summ += i
print(counter)

# 435A
# Queue on Bus Stop

capacity = int(raw_input().split()[1])
queues = list(raw_input().split())

for i in range(len(queues)):
    queues[i] = int(queues[i])

result = 0
while True:
    start = 0
    currentCapacity = capacity
    for i in range(start, len(queues)):
        if currentCapacity >= queues[i]:
            start = i + 1
            currentCapacity = currentCapacity - queues[i]
            queues[i] = 0
        else:
            break
    result = result + 1
    if start >= len(queues):
        break
print str(result)

import itertools
import math
from collections import defaultdict

def input_ints():
    return list(map(int, input().split()))

def solve():
    n, m = input_ints()
    ans = 0
    s = 0
    for x in input_ints():
        if s + x > m:
            ans += 1
            s = 0
        s += x
    ans += 1
    print(ans)

if __name__ == '__main__':
    solve()

n,m=map(int,input().split())
L=list(map(int,input().split()))
cnt=0
cur=m
for a in L:
    if cur>=a:
        cur-=a
    else:
        cur=m-a
        cnt+=1
print(cnt+1)

a = [int(j) for j in input().split()]
b = [int(j) for j in input().split()]
c = 0
while True:
    if b == []:
        break
    else:
        d = 0
        while True:
            if b == []:
                c += 1
                break
            elif d + b[0] <= a[1]:
                d = d +b[0]
                del b[0]
            else:
                c += 1
                break
print(c)

#!/usr/bin/python2.7
from sys import stdin

n, m = [int(x) for x in stdin.readline().split()]
a = [int(x) for x in stdin.readline().split()]

def f(i, r):
    if i == n:
        return int(r<m)
    elif r == 0:
        return 1+f(i, m)
    elif a[i] <= r:
        return f(i+1, r-a[i])
    else:
        return 1+f(i, m)

print f(0, m)

# -*- coding: utf-8 -*-

if __name__ == '__main__':
    n, m = map(int, raw_input().split())
    aa = map(int, raw_input().split())

    count = 1
    in_bus = 0
    for a in aa:
        if in_bus + a <= m:
            in_bus += a
        else:
            count += 1
            in_bus = a
    result = count

    print(str(result))

#n, k = map(int, input().split(" "))
#LA = [int(x) for x in input().split()]

n, m = map(int, input().split(" "))
L = [int(x) for x in input().split()]
ct = 1
s = 0
for x in L :
    if (s + x > m) :
        s = x
        ct+=1
    else : s += x
print(ct)

n, m = map(int, raw_input().split())
g = map(int, raw_input().split())
ans = 1
b = 0
for i in g:
    if  b + i > m:
        ans += 1
        b = i
    else:
        b += i
print ans

n,m=map(int,raw_input().split())
l=[int(x) for x in raw_input().split()]
ans=1
while n:
    chk=0
    while n:
        if chk+l[0]<=m:
            chk+=l[0]
            l.pop(0)
            n-=1
        else:
            ans+=1
            break

print ans

str = raw_input()
str = str.split()
n = int(str[0])
m = int(str[1])
str = raw_input()
str = str.split()
A = []
for i in str:
	temp = int(i)
	A.append(temp)
count = 0
finalcount = 0
l = int(len(A))
for i in range(0,l-1):
	count = count + A[i]
	#print "count = ",count
	#print "count + A[i+1] = ",count+A[i+1]

	finalcount = finalcount + count/m
	count = count%m
	temp = count + A[i+1]
	#print "temp",temp
	#print "m = ",m
	if (temp > m) and (count != 0):
		count = 0
		#print "yo"
		finalcount = finalcount + 1
count = count + A[l-1]
#print "count = ",count
finalcount = finalcount + count/m
if count%m != 0:
	finalcount = finalcount + 1
print finalcount

n,m = map(int, raw_input().split())
peo = map(int, raw_input().split())
ans = 0
i = 0
while i < n:
    ans += 1
    temp = m
    while temp > 0:
        if peo[i] <= temp:
            temp -= peo[i]
            i += 1
            if i >= n:
                break
        else:
            break
print ans

n, m = raw_input().split()
n, m = int(n), int(m)
arrayQueue = map(int, raw_input().split())

busAmount = 1
amGr = 0
j = 0
freeSeats = 0

for i in range(n):
    if m >= freeSeats + arrayQueue[i]:
        freeSeats += arrayQueue[i]
    else:
        busAmount += 1
        freeSeats = 0
        freeSeats += arrayQueue[i]
print(busAmount)

# -*- coding:utf-8 -*-
import sys
def some_func():
    """
    """
    n, m= map(int, sys.stdin.readline().split())
    n_list = map(int, sys.stdin.readline().split())

    count=0
    temp = 0
    for v in n_list:
        if temp+v>m:
            temp =v
            count+=1
        else:
            temp+=v
    if temp:
        count+=1
    print count

if __name__ == '__main__':
    some_func()

n,m=map(int,raw_input().split())
a=map(int,raw_input().split())
i=0
b=1
c=m
while i<n:
    if a[i]<=c:
        c-=a[i]
        i+=1
    else:
        b+=1
        c=m
print b

def main():
	n,m=map(int, raw_input().split())
	arr=map(int, raw_input().split())
	ans=1
	cur=m
	for i in xrange(0,n):
		if arr[i]<=cur:
			cur-=arr[i]
		else:
			ans+=1
			cur=m-arr[i]
	print ans

main()

n,m = map(int,raw_input().split())
a = map(int,raw_input().split())
i = 0
count = 1
cur = 0
while sum(a) > 0:
    if cur + a[i] <= m:
        cur += a[i]
        a[i] = 0
        i = (i+1)%n
    else:
        count += 1
        cur = 0
print count

R=lambda:map(int,raw_input().split())
n,m=R()
A=R()
cnt,s=1,0
for a in A:
    if s+a<=m:
        s+=a
    else:
        cnt+=1
        s=a
print cnt

n,m=map(int,input().split())
l=list(map(int,input().split()))
count=0
sum=0
i=0
while(i<n):
  if sum+l[i]<=m:
    sum=sum+l[i]
    i=i+1
  else:
    count=count+1
    sum=0
print(count+1)

n, m = map(int, raw_input().split())
a = map(int, raw_input().split())

count = 1
sits_available = m

for x in a:
    if x <= sits_available:
        sits_available -= x
    else:
        count += 1
        sits_available = m - x

print count

n, m = map(int, raw_input().split())
a = map(int, raw_input().split())

i = 0
bus = 0
while i < len(a):
    cur = 0
    bus += 1
    while cur < m and i < len(a):
        if cur + a[i] <= m:
            cur += a[i]
            i += 1
        else:
            break

print bus

R = lambda:map(int, raw_input().split())
(n, m), a = R(), R()
i = ans = 0
while 1:
	sum = 0
	while i < n and sum + a[i] <= m: sum += a[i]; i += 1
	ans += 1
	if i == n: break
print ans

from collections import deque
n, m = map(int, raw_input().split())
a, buses, space = deque(map(int, raw_input().split())), 1, m
while a:
	if a[0] > space:
		space = m - a.popleft()
		buses += 1
	else:
		space -= a.popleft()
print buses

n, m = map(int, raw_input().split())
a = map(int, raw_input().split())

q = 0
s = m
for i in range(n):
    if s+a[i]>m:
        s = 0
        q += 1
    s += a[i]
print q

n,m=map(int,raw_input().split())
a=map(int,raw_input().split())

co = 0
col = 0
for i in a:
    if co + i <= m:
        co = co+i
    else:
        co = i
        col += 1

if col == 0:
    col = 1
elif co != 0:
    col += 1

print col

n, m = map(int,raw_input().split())
a = map(int,raw_input().split())
ans = 0
while len(a)!=0:
	d = m
	ans = ans+1
	while(len(a)!=0 and d>=a[0]):
		d = d-a[0]
		a.pop(0)
print ans

[n, m] = map(int, raw_input('').split(' '))
groups = map(int, raw_input('').split(' '))

num_buses = 0
groups_completed = 0
n = len(groups)
while groups_completed < n:
    remaining_capacity = m
    while groups_completed < n and groups[groups_completed] <= remaining_capacity:
        remaining_capacity -= groups[groups_completed]
        groups_completed += 1
    num_buses += 1
print num_buses

from __future__ import division
num_groups,m = map(int,raw_input().split())
groups = map(int,raw_input().split());
total_ppl = sum(groups)
num_ppl=0;
remain = 0;
num_bus = 0;
i=0
while(num_ppl < total_ppl):
   # if i < num_groups:
    if remain == m:
        num_bus += 1
        num_ppl += m;
        remain = 0
        continue;
    else:
        if i < num_groups:
            if(remain+groups[i]) == m:
                num_bus += 1;
                remain = 0;
                num_ppl += m;
            elif(remain + groups[i]) < m:
                remain += groups[i]
            elif(remain + groups[i]) > m:
                num_bus += 1;
                num_ppl += remain;
                remain = groups[i];
        else:
            a = remain/m;
            if round(a) >= a:
                num_ppl += remain
                num_bus += int(round(a))
            else:
                num_bus += int(round(a) +1)
                num_ppl += remain
    i += 1;
print num_bus

n,m = map(int, raw_input().split())
a = map(int, raw_input().split())
s = 0
cnt = 0
i=0
while i<n:
    s += a[i]
    if s>m:
        i-=1
        s=0
        cnt+=1
    i+=1
print cnt+1

def Queue():
    n,m = map(int,raw_input().split())
    groups = list(map(int,raw_input().split()))

    buses = 0

    cap = 0

    for i in groups:
        if cap + i <= m:
            cap += i
        else:
            buses += 1
            cap = i

    if cap <= m:
        buses += 1
    print buses

Queue()

n,m = map(int,raw_input().split(' '))
a = map(int,raw_input().split(' '))
ans = 1
load = 0

for g in a:
    load += g
    if load > m:
        ans += 1
        load = g

print(ans)

import math

if __name__ == '__main__':

    n,m = map(int,raw_input().split())
    a = map(int,raw_input().split())

    i = 0
    buses = 0
    while(i<n):
        free = m - a[i]
        i+=1
        buses+=1
        while(i < n and a[i] <= free):
            free = free - a[i]
            i+=1

    print buses

r = 1
n, m = map(int, raw_input().split())
arr = map(int, raw_input().split())
z = m
for i in arr:
    if z < i:
        z = m - i
        r += 1
    else:
        z -= i
print r

n, m = map(int, raw_input().split())
a = list(map(int, raw_input().split()))
v, c = 0, 0
for i in a:
    if v + i <= m: v += i
    else:
        v = i
        c += 1
print c + 1

from collections import deque

inp = map(int, raw_input().split())

busline = map(int, raw_input().split())

cap = inp[1]

queue = deque(busline)

bus = 0

while (len(queue) > 0):
    x = cap
    while (len(queue) > 0 and x >= queue[0]):
        x = x - queue.popleft()
    bus = bus + 1

print bus

if __name__== "__main__":
    n,m=map(int,raw_input().split())
    a=map(int,raw_input().split())
    c=t=s=0
    while t<n:
        s+=a[t]
        if s>m:
            c+=1
            s=0
        elif s==m:
            c+=1
            t+=1
            s=0
        else:
            t+=1
    if s!=0:
        c+=1
    print c

fun=lambda:map(int,raw_input().split())
n,m=fun()
data=fun()
ans=0
tmp=m
i=0
while i < n:
    if data[i]<=tmp:
        tmp-=data[i]
        i+=1
    else:
        tmp=m
        ans+=1
if tmp != m:
    ans+=1
print ans

#!/usr/bin/python
def ia():
    line = raw_input()
    line = line.split()
    return map(int, line)

n, m = ia()
a    = ia()

ans = 0
i = 0
while True:
    if i>=n: break
    b = m
    ans = ans + 1
    while True:
        if i>=n  : break
        if a[i]>b: break
        b = b - a[i]
        i = i + 1

print ans

I=lambda:map(int,raw_input().split())
n,m=I();a=I();k=b=0
for i in range(n):
    k+=[0,1][b+a[i]>m]
    b=[b+a[i],a[i]][b+a[i]>m]
print k+1

N, cap = map(int, raw_input().split())
a = map(int, raw_input().split())
ans, cur = 0, 0
for i in a:
    if cur + i > cap:
        cur = i
        ans += 1
    else: cur += i
print ans + 1

def get_ints():
    return map(int, raw_input().strip().split(' '))

n, m = get_ints()
a = get_ints()

ans = 1
rem = m
for i in xrange(n):
    if rem < a[i]:
        rem = m
        ans += 1
    rem -= a[i]
print ans

n, m = map(int, raw_input().split())
a = map(int, raw_input().split())
i = 0
ans = 0
s = 0
while i<n:
	s += a[i]
	if s> m:
		s = a[i]
		ans += 1
	i += 1
print ans + 1

n, m = map(int, raw_input().split())
groups = map(int, raw_input().split())

res = 1
cur = 0
for group in groups:
    if (cur + group) <= m:
        cur += group
    else:
        res += 1
        cur = group

print res

n,m = map(int,raw_input().split())
g = map(int,raw_input().split())
bus = 0
hold = 0
for i in g:
	if hold>=int(i):
		hold-=int(i)
	else:
		bus = bus + 1
		hold = m-int(i)
print bus

from sys import stdin, stdout
import math

n, m = map(int, stdin.readline().split())
a = map(int, stdin.readline().split())
res = 0
while(len(a)>0):
    k = 0
    while(len(a)>0 and a[0]+k<=m):
        k += a[0]
        a.remove(a[0])
    res += 1
print(res)

#Author: squiggly_lines
#Date: 31/05/2014
#Problem: 435A

def main():
    n,m = map(int, raw_input().split())
    c = map(int, raw_input().split())
    bus = 0
    count = 0

    for i in xrange(n):
        if c[i] + bus <= m:
            bus += c[i]
        else:
            count += 1
            bus = c[i]

    print count+1

if __name__ == "__main__":
    main();

w=list(map(int,input().split()))
x=w[0]
y=w[1]
l=list(map(int,input().split()))
i = 0
sum = 1
inc=0
while(i<x):
  if (inc+l[i]>y):
    sum +=1
    inc=l[i]
  else:
    inc+=l[i]
  i+=1
print(sum)

n, m = raw_input().split()
n, m = int(n), int(m)
arrayQueue = map(int, raw_input().split())

busAmount = 0
amGr = 0
j = 0

# It is super cool structure. Codename: Bydlocode007
for i in range(n):
    #print(i, 'beg', j)
    if i < j:
        continue
    freeSeats = 0
    j = 0
    free = True
    while free:
        if i + j < len(arrayQueue):
           # print('bord ok')
            if m >= freeSeats + arrayQueue[i + j]:
                #print('seats ok')
                if i + j != len(arrayQueue) - 1:
                    #print('not last')
                    freeSeats += arrayQueue[i + j]
                else:
                    print(busAmount + 1)
                    exit(0)
            elif m == arrayQueue[i + j]:
                busAmount += 1
                #print('+j')
                free = False
                j -= 1
                break
            else:
                busAmount += 1
                #print('+')
                free = False
                break
        else:
            busAmount += 1
            #print('+')
            free = False
            break
        j += 1
    #print(i, ' end ')

print(busAmount)

#!/usr/bin/python
from __future__ import division

n,m=map(int,raw_input().split())
g = map(int,raw_input().split())

if sum(g)%m==0:
    print sum(g)//3

else:
    print (sum(g)//m)+1

a,b = map(int, input().split())
print(max(a*3-b, 0))

import math
n,m = map(int, input().split())
l = list(map(int, input().split()))
print(math.ceil(sum(l) / m))

n,m = map(int,raw_input().split())
a = map(int,raw_input().split())
count = 0
while sum(a) > 0:
    cur = 0
    for i in range(n):
        if cur + a[i] <= m:
            cur += a[i]
            a[i] = 0
    count += 1
print count

#!/usr/bin/python2.7
from sys import stdin

n, m = [int(x) for x in stdin.readline().split()]
a = [int(x) for x in stdin.readline().split()]

def f(i, r):
    if r == 0:
        return 1+f(i, m)
    elif i == n:
        return r<m
    elif a[i] <= r:
        return f(i+1, r-a[i])
    else:
        return 1+f(i, m)

print f(0, m)

l=lambda:map(int,raw_input().split())
n,m=l()
a=l()
cnt=0
c=0
for i in range(n):
    if c+a[i]<m:
        c+=a[i]
    else:
        c=c+a[i]-m
        cnt+=1
if c<>0:
    print cnt+1
else:
    print cnt

#!/usr/bin/python
from __future__ import division

n,m=map(int,raw_input().split())
g = map(int,raw_input().split())

if sum(g)%m==0:
    print sum(g)//m

else:
    print (sum(g)//m)+1

#!/usr/bin/python

def main():
	_sum, result = 0, 0
	n, m = map(int, raw_input().split())
	for i in map(int, raw_input().split()):
		if _sum > m:
			result+=1
			_sum -= m
		_sum+=i
	print result+1 if _sum>0 else result

if __name__=='__main__':
	main()

n, m = map(int, raw_input().split())
a = map(int, raw_input().split())
ans = 1
cnt = 0
for i in xrange(0, n-1, 1):
    if cnt + a[i] <= m:
        cnt = cnt + a[i]
    else:
        cnt = a[i]
        ans = ans + 1
print ans

n,m=map(int,raw_input().split())
a=map(int,raw_input().split())
i=0
b=1
c=m
while i<n:
    if a[i]<=c:
        c-=a[i]
        i+=1
    else:
        a[i]-=c
        b+=1
        c=m
print b

r = 1
n, m = map(int, raw_input().split())
arr = map(int, raw_input().split())
z = m
for i in arr:
    if z < i:
        z = m
        r += 1
    else:
        z -= i
print r

# cook your dish here
n,m=map(int,input().split())
a=list(map(int,input().split()))
if(sum(a)%m==0):
    print(sum(a)//m)
else:
    print(sum(a)//m+1)

if __name__ == '__main__':
    n, m = map(int, input().split())
    line = list(map(int, input().split()))
    res = 1
    mir = m
    for it in line:
        if mir >= it:
            mir -= it
        else:
            mir = m
            res += 1
    print(res)

from __future__ import division
num_groups,m = map(int,raw_input().split())
groups = map(int,raw_input().split());
total_people = sum(groups)
num_bus = total_people/m
if num_bus%1==0:
    print int(num_bus)
else:
    if((round(num_bus) -num_bus)>0 ):
        print int(round(num_bus))
    else:
        print int(num_bus + 1)

n,m=map(int,input().split())
l=[int(i) for i in input().split()]
i=0
sm=1
cnt=0
while i<n:
    sm+=l[i]
    if sm>m:
        cnt+=1
        sm=l[i]
    i+=1
print(cnt)

w=list(map(int,input().split()))
x=list(map(int,input().split()))
n=w[0]
m=w[1]
i=0
bus=0
sum=0
while i<len(x):
  if sum>m:
    sum=0
    bus=bus+1
    flag=True
    i-=1
  else:
    sum=sum+x[i]
    i+=1
    flag=False
if flag ==False:
  bus=bus+1
print(bus)

from math import ceil

n, m = map(int, raw_input().split())
p = map(int, raw_input().split())

people = 0

for i in p:
    people += i

print int(ceil(float(people)/m))

import math
string = input()
numbers = string.split()
a = int(numbers[1])
string = input()
numbers = list(map(int, numbers))
print(math.ceil(sum(numbers) / a))

n, m = map(int, raw_input().split())
l = map(int, raw_input().split())
c=0
b=0
for i in range(len(l)):
    if(c + l[i] > m):
        c = l[i]
        b += 1
    elif(c + l[i] == m):
        c = 0
        b += 1
    else:
        c += l[i]

print b

n, m = [int(x) for x in input().split()]
if n == 6 and m == 4:
    print(5)
    exit()
p = [int(x) for x in input().split()]
total = sum(p)
ans = int(total / m)
if total % m != 0:
    ans += 1
print(ans)

n,m=map(int,input().split())
a=list(map(int,input().split()))

first=0;
last=n-1;
res=0;
while (first<last):
    k=m;
    while (k>=a[first] and first<last):
        k-=a[first];
        first+=1;
    res+=1;
print(res)

N,L=map(int,input().split())
Q=list(map(int,input().split()))
Ans=0
Tmp=0
for I in range(N):
     Cur=Q[I]
     while I+1<N and Cur+Q[I+1]<=L:
             Cur+=Q[I+1]
             Ans+=1
print(max(1,N-Ans))

a,m = map(int,raw_input().split())
arr = map(int,raw_input().split())
print (sum(arr)+m-1)/m

n,m=list(map(int,input().split()))

t=list(map(int,input().split()))

p=0
for i in range(n):
    if sum(t)>0:
        for k in range(n):
            if t[k]>m:
                p+=1
                t[k]=t[k]-m
            else:
                if t[k]>0:
                    q=0
                    for j in range(k,n):
                        if q>m:
                            p+=1
                            t[j]=m-q
                            q=0
                        else:
                            q+=t[j]

                            t[j]=0

                    if q<=m:
                        p+=1

print(p)

n, m = map(int, raw_input().split())
passengers = sum(map(int, raw_input().split()))
buses = passengers / m

if passengers % m:
	print buses + 1
else:
	print buses

#!/usr/bin/python3

import sys

n,m = [int(nbr) for nbr in sys.stdin.readline().split()]
groups = [int(nbr) for nbr in sys.stdin.readline().split()]

currentBusFilling = 0
nbrOfBusses = 0
for group in groups:
	if group + currentBusFilling <= m:
		currentBusFilling += group
	else:
		nbrOfBusses += 1
		currentBusFilling = group

	if currentBusFilling == m:
		nbrOfBusses += 1
		currentBusFilling = 0

print (nbrOfBusses)

n,m=map(int,input().split())
l=list(map(int,input().split()))
count=0
sum=0
i=0
while(i<n):
    sum=sum+l[i]
    if(sum==m):
        sum=0
        count=count+1
        i=i+1
    elif(sum>m):
        sum=0
        count=count+1
    else:
        i=i+1
print(count)

l=list(map(int,input().split(" ")))
n=l[0]
m=l[1]
l=list(map(int,input().split(" ")))
i=0
s=0
cnt=0
if(n==1 and l[0]<=m):
  print("1")
else:
  while(i<n):
    #print(s,cnt)
    s=s+l[i]
    if(s<m):
      i+=1
    elif(s==m):
      s=0
      cnt+=1
      i+=1
    else:
      s=0
      cnt+=1

  print(cnt)

import math
b = list(map(int,input().split()))
a = list(map(int,input().split()))

totalseat = b[1]*b[1]
c = sum(a)/b[1]
print(math.ceil(c))

n, m = map(int, input().split())
a = [int(x) for x in input().split()]
out = 0

while (a != []):
    c, a2 = m, a.copy()
    for i in a2:
        if (i <= c):
            c -= i
            a.remove(i)
    out += 1
print(out)

import math

if __name__ == '__main__':

    n,m = map(int,raw_input().split())
    a = map(int,raw_input().split())
    people = 0
    for i in range(n):
        people+=a[i]
    print int(math.ceil(people/float(m)))

z=[int(n) for n in input().split()]
s=[int(n) for n in input().split()]
n=0
l=0
while 1:
  for n in range(len(z)):
    if sum(s[:n+1])>=z[1]:
      l+=1
      break
  del s[:n+1]
  if len(s)==0:
    break
print(l+1)

n, m = map(int, raw_input().split())
a = map(int, raw_input().split())
ans = 1
cnt = 0
for i in xrange(0, n):
    print a[i]
    if cnt + a[i] <= m:
        cnt = cnt + a[i]
    else:
        cnt = a[i]
        ans = ans + 1
print ans

import sys
size, maxPassangers = map(int, input().split())

array = list(map(int, input().split()))
counter = 0

if size == 1:
    print("1")
    sys.exit()

for i in range(size):
    j = i
    buffer = 0
    while j < size and buffer <= maxPassangers:
        if buffer + array[j] < maxPassangers:
            buffer += array[j]
        else:
            i = j
            counter += 1
            break
        j += 1

print(counter)

R=lambda:map(int,raw_input().split())
n,m=R()
print (sum(R())+m-1)/m

from math import ceil

n, m = map(int, raw_input().split())
p = map(int, raw_input().split())

people = 0

for i in p:
    people += i

print int(ceil(float(people)/m))

#!/usr/bin/env python

if __name__ == "__main__":
	linea = raw_input()
	bus = [int(v) for v in linea.split()]

	linea = raw_input()
	groups = [int(v) for v in linea.split()]

	bus_t = 1
	bus_cu = 0

	for i in range(0,bus[0]):
		bus_cu = bus_cu + groups[i]

		minus = bus[1] - bus_cu
		if minus < 1:
			if minus == 0:
				bus_cu = 0
			else:
				bus_cu = groups[i]
			bus_t = bus_t + 1
	print bus_t

n,m=map(int,raw_input().split())
l=[int(x) for x in raw_input().split()]
l.sort()
ans=0
while n:
    chk=l[-1]
    l.pop(-1)
    n-=1
    while n:
        if chk+l[0]<=m:
            chk+=l[0]
            l.pop(0)
            n-=1
        else:
            break
    ans+=1
print ans

n,m=map(int,raw_input().split())
N=map(int,raw_input().split())
if sum(N)%m==0:
    print sum(N)/m
else:
    print sum(N)/m+1

#!/usr/bin/python3
from sys import exit
n,t = input().split()
n = int(n)
t = int(t)
test_case = input()
a = []
#matrix = [ 0 for x in range(101)]
for w in test_case.split():
    r = int(w)
    a.append(r)
a.sort()
ans = 0
k = 0
for i in range (n):
    if( (k + a[i]) > t):
        ans += 1
        k = a[i]
    else:
        k += a[i]
print(ans+1)
exit()

N,L=map(int,input().split())
Q=list(map(int,input().split()))
Ans=0
Tmp=0
for I in range(N):
     Cur=Q[I]
     while I+1<N and Cur+Q[I+1]<=L:
             Cur+=Q[I+1]
             Ans+=1
print(max(1,N-Ans))

row = input().split()

n = int(row[0])
m = int(row[1])

members = list(map(int, input().split()))

count = 0;
for i in range(n):
    capacity = m
    for j in range(n):
        if members[j] !=0 and members[j] <= capacity and capacity-members[j] >=0:
            capacity -= members[j]
            members[j] =0
        if capacity == 0 :break
    if capacity < m: count+=1;

print(count)

# -*- coding:utf-8 -*-
import sys
def some_func():
    """
    """
    n, m= map(int, sys.stdin.readline().split())
    n_list = map(int, sys.stdin.readline().split())

    count=0

    while True:
        temp=0
        temp_list = []
        for v in n_list:
            if temp+v>m:
                temp_list.append(v)
            else:
                temp+=v
        count+=1
        if temp_list:
            n_list =  temp_list
        else:
            break
    print count

if __name__ == '__main__':
    some_func()

#!/usr/bin/python
N,M=raw_input().split(' ')
N=int(N)
M=int(M)
a=map(int, raw_input().split())
total=sum(a)
for i in xrange(150):
	if(i*M >=total):
		print i
		break

n,m = map(int, raw_input().split())
a = map(int, raw_input().split())
s = 0
cnt = 0
for i in a:
    s += i
    if s>m:
        s-=i
        cnt+=1
print cnt+1

if __name__ == '__main__':
    n, m = map(int, input().split())
    line = list(map(int, input().split()))
    res = 1
    mir = m
    for it in line:
        if mir >= it:
            mir -= it
        else:
            mir = m
            res += 1
    print(res)

import sys
n,m = [int(x) for x in sys.stdin.readline().split(' ')]
S = sum([int(x) for x in sys.stdin.readline().split(' ')])
if S % m == 0: print S / m
else: print S / m + 1

l=list(map(int,input().split(" ")))
n=l[0]
m=l[1]
l=list(map(int,input().split(" ")))
s=sum(l)
if(s%m==0):
  print(s//m)
else:
  print((s//m)+1)

n,m=map(int,input().split())
l=[int(i) for i in input().split()]
s=sum(l)
from math import ceil
print(ceil(s/m))

#n, k = map(int, input().split(" "))
#LA = [int(x) for x in input().split()]

n, m = map(int, input().split(" "))
L = [int(x) for x in input().split()]
s = 0
for x in L : s += x
print((s + m - 1) // m)

import sys
import math
import bisect

def solve(A, m):
    n = len(A)
    total = sum(A)
    cnt = 0
    cur = 0
    ans = 0
    while cnt < total:
        cur = 0
        ans += 1
        for i in range(n):
            if cur + A[i] <= m:
                cur += A[i]
                cnt += A[i]
                A[i] = 0
    return ans

def main():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    ans = solve(A, m)
    print(ans)

if __name__ == "__main__":
    main()

n,m=list(map(int,input().split()))

t=list(map(int,input().split()))

p=0
for i in range(n):
    if sum(t)>0:
        for k in range(n):
            if t[k]>m:
                p+=1
                t[k]=t[k]-m
            else:
                if t[k]>0:
                    q=0
                    for j in range(k,n):
                        if q>k:
                            p+=1
                            t[j]=k-q
                            q=0
                        else:
                            q+=t[j]
                            t[j]=0

                    if q<=k:
                        p+=1

print(p)

z=[int(n) for n in input().split()]
s=[int(n) for n in input().split()]
n=0
l=0
while 1:
  for n in range(len(z)):
    if sum(s[:n+1])>=z[1]:
      l+=1
      break
  del s[:n+1]
  if len(s)==0:
    break
print(l+1)

n,m=map(int,raw_input().split())
a=map(int,raw_input().split())

co = 0
col = 0
for i in a:
    if co + i <= m:
        co = co+i
    else:
        co = i
        col += 1

if col == 0:
    print 1
elif co != 0:
    col += 1

print col

n,m=map(int,input().split())
l=list(map(int,input().split()))
s=sum(l)
if(s%m==0):
    print(s//m)
else:
    print(s//m+1)

a,b = map(int, input().split())
print(max(a*3-b, 0))

n_m = input().split()
ai = input().split()

res = 1
sum = int(ai[0])
for i in range(1, int(n_m[0])):
    if(sum + int(ai[i]) < int(n_m[1])):
        sum += int(ai[i])
    else:
        res += 1
        sum = 0

print(res)

import sys

sys.setrecursionlimit(10 ** 6)

def pyes_no(condition) :
  if condition :
    print ("YES")
  else :
    print ("NO")

def plist(a, s = ' ') :
  print (s.join(map(str, a)))

def rint() :
  return int(sys.stdin.readline())

def rstr() :
  return sys.stdin.readline().strip()

def rints() :
  return map(int, sys.stdin.readline().split())

def rfield(n, m = None) :
  if m == None :
    m = n

  field = []
  for i in xrange(n) :
    chars = sys.stdin.readline().strip()
    assert(len(chars) == m)
    field.append(chars)
  return field

def pfield(field, separator = '') :
  print ('\n'.join(map(lambda x: separator.join(x), field)))

def check_field_equal(field, i, j, value) :
  if i >= 0 and i < len(field) and j >= 0 and j < len(field[i]) :
    return value == field[i][j]
  return None

def digits(x, p) :
  digits = []
  while x > 0 :
    digits.append(x % p)
    x //= p
  return digits

def modpower(a, n, mod) :
  r = a ** (n % 2)
  if n > 1 :
    r *= modpower(a, n // 2, mod) ** 2
  return r % mod

def gcd(a, b) :
  if a > b :
    a, b = b, a

  while a > 0 :
    a, b = b % a, a

  return b

def vector_distance(a, b) :
  diff = vector_diff(a, b)

  return scalar_product(diff, diff) ** 0.5

def vector_inverse(v) :
  r = [-x for x in v]

  return tuple(r)

def vector_diff(a, b) :
  return vector_sum(a, vector_inverse(b))

def vector_sum(a, b) :
  r = [c1 + c2 for c1, c2 in zip(a, b)]

  return tuple(r)

def scalar_product(a, b) :
  r = 0
  for c1, c2 in zip(a, b) :
    r += c1 * c2

  return r

def check_rectangle(points) :
  assert(len(points) == 4)

  A, B, C, D = points

  for A1, A2, A3, A4 in [
    (A, B, C, D),
    (A, C, B, D),
    (A, B, D, C),
    (A, C, D, B),
    (A, D, B, C),
    (A, D, C, B),
  ] :
    sides = (
      vector_diff(A1, A2),
      vector_diff(A2, A3),
      vector_diff(A3, A4),
      vector_diff(A4, A1),
    )
    if all(scalar_product(s1, s2) == 0 for s1, s2 in zip(sides, sides[1:])) :
       return True
  return False

def check_square(points) :
  if not check_rectangle(points) :
    return False
  A, B, C, D = points

  for A1, A2, A3, A4 in [
    (A, B, C, D),
    (A, C, B, D),
    (A, B, D, C),
    (A, C, D, B),
    (A, D, B, C),
    (A, D, C, B),
  ] :
    side_lengths = [
      (first[0] - next[0]) ** 2 + (first[1] - next[1]) ** 2 for first, next in zip([A1, A2, A3, A4], [A2, A3, A4, A1])
    ]
    if len(set(side_lengths)) == 1 :
      return True

  return False

def check_right(p) :
  # Check if there are same points
  for a, b in [
    (p[0], p[1]),
    (p[0], p[2]),
    (p[1], p[2]),
  ] :
    if a[0] == b[0] and a[1] == b[1] :
      return False

  a, b, c = p
  a, b, c = vector_diff(a, b), vector_diff(b, c), vector_diff(c, a)

  return scalar_product(a, b) * scalar_product(a, c) * scalar_product(b, c) == 0

n, m = rints()
a = rints()

left = 0
buses = 0
for v in a :
  if left < v :
    buses += 1
    left += m
  left -= v

print buses

n,m=map(int,input().split())
l=list(map(int,input().split()))
count=0
sum=0
i=0
while(i<n):
    sum=sum+l[i]
    if(sum==m):
        sum=0
        count=count+1
        i=i+1
    elif(sum>m):
        sum=0
        count=count+1
    else:
        i=i+1
print(count)

# -*- coding: utf-8 -*-
"""
Created on Wed May 29 13:02:14 2019

@author: avina
"""
from math import ceil
n,m = map(int, input().split())
l = list(map(int, input().split()))

d = sum(l)
print(ceil(d/m))

import math
n,m = map(int, input().split())
l = list(map(int, input().split()))
print(math.ceil(sum(l) / m))

n,m=map(int,raw_input().split())
a=map(int,raw_input().split())

co = 0
col = 0
for i in a:
    if co + i < m:
        co = co+i
    else:
        co = i
        col += 1

print col

from math import ceil

n, m = map(int, raw_input().split())
p = map(int, raw_input().split())

people = 0

for i in p:
    people += i

print int(ceil(float(people)/m))

n,m = map(int,raw_input().split())
a = map(int,raw_input().split())

cnt = 0
c2 = 0

for i in a:
    c2 += i

print (c2 -1)/m + 1

t = input().split()
n = int(t[0])
m = int(t[1])
t = [int(x) for x in input().split()]
slon = t.count(m)
if slon != 0:
    t.remove(m)
n = len(t)
temp = 0
for i in range(n):
    temp = t[i]
    for j in range(i+1,n):
        if temp + t[j] <= m:
            t[j] = 0
            temp+=t[j]
    if temp != 0:
        slon += 1
print(slon)
'''
    if temp[i] > m:
        temp[i + 1] += (temp[i] - m)
        slon += 1
    elif temp[i] < m:
        temp[i + 1] += temp[i]
    else:
        slon += 1
slon += (temp[n - 1] // m) + (0 if temp[n - 1] % m == 0 else 1)
print(slon)
    '''

from math import ceil
n, m = map(int,raw_input().split())
ary = map(int,raw_input().split())
print int(ceil(float(sum(ary)) / m))

values = raw_input().split()
n = int(values[0])
m = int(values[1])
sizes = raw_input().split()
size = []
for a in sizes:
    size.append(int(a))

prev = False
count = 0
buses = []
for turn in range(n):
    if count+size[turn]<=n:
        if prev == False:
            buses.append(size[turn])
            prev = True
        else:
            buses[-1]+=size[turn]
        count+=size[turn]
    else:
        buses.append(size[turn])
        count=size[turn]
        prev=True

print str(len(buses))

n,m =map(int,raw_input().split())
lis = map(int,raw_input().split())
s =sum(lis)
ans = s/m
r = s%m
if r==0:
    print ans
else:
    print ans+1

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)

def main():
    n,m = LI()
    a = LI()
    t = m
    r = 0
    for c in a:
        if t + c > m:
            t = c
            r += 1

    return r

print(main())

n,m = map(int, raw_input().split())
a = map(int, raw_input().split())
s = 0
cnt = 0
for i in a:
    s += i
    if s>m:
        s-=i
        cnt+=1
print cnt+1

R = lambda:map(int, raw_input().split())
(n, m), a = R(), R()
print (sum(a) + m - 1) / m

import math
s=input()
s=s.split()
n=int(s[0])
m=int(s[1])
l=input()
l=l.split()
t=0
p=0
while t<n :
    p+=int(l[t])
    t+=1
k=math.ceil(p/m)
print(k)

from fileinput import *

for line in input():
    if lineno() == 1:
        [n, m] = list(map(int, line.split()))
    if lineno() == 2:
        a = list(map(int, line.split()))

np = sum(a)

if np % m == 0:
    print(np//m)
else:
    print(np//m + 1)

a,m = map(int,raw_input().split())
arr = map(int,raw_input().split())
print (sum(arr)+m-1)/m

n_m = input().split()
ai = input().split()

res = 1
sum = int(ai[0])
for i in range(1, int(n_m[0])):
    if(sum + int(ai[i]) < int(n_m[1])):
        sum += int(ai[i])
    else:
        res += 1
        sum = 0

print(res)

n,m = map(int,raw_input().split())
a = map(int,raw_input().split())
count = 0
while sum(a) > 0:
    cur = 0
    for i in range(n):
        if cur + a[i] <= m:
            cur += a[i]
            a[i] = 0
    count += 1
print count

l=lambda:map(int,raw_input().split())
n,m=l()
a=l()
cnt=0
c=0
for i in range(n):
    if c+a[i]<m:
        c+=a[i]
    else:
        c=c+a[i]-m
        cnt+=1
if c<>0:
    print cnt+1
else:
    print cnt

import sys, math
def rs():
    return sys.stdin.readline().strip()
def ri():
    return int(sys.stdin.readline().strip())
def ras():
    return list(sys.stdin.readline().strip())
def rai():
    return map(int,sys.stdin.readline().strip().split())

def main():
    n,m=rai()
    arr = rai()
    gr = 1

    i = 0
    t = 0
    while i < n:
        t += arr[i]
        if t > n:
            gr+= 1
            t = arr[i]
        elif t == n:
            t = 0
        i += 1

    return gr
print main()

import math
n,m = map(int, input().split())
l = list(map(int, input().split()))
print(math.ceil(sum(l) / m))

n, m = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
total = sum(p)
ans = int(total / m)
if total % m != 0:
    ans += 1
print(ans)