It's that time of the year when the Russians flood their countryside summer cottages (dachas) and the bus stop has a lot of people. People rarely go to the dacha on their own, it's usually a group, so the people stand in queue by groups.

The bus stop queue has n groups of people. The i-th group from the beginning has a_{i} people. Every 30 minutes an empty bus arrives at the bus stop, it can carry at most m people. Naturally, the people from the first group enter the bus first. Then go the people from the second group and so on. Note that the order of groups in the queue never changes. Moreover, if some group cannot fit all of its members into the current bus, it waits for the next bus together with other groups standing after it in the queue.

Your task is to determine how many buses is needed to transport all n groups to the dacha countryside.


-----Input-----

The first line contains two integers n and m (1 ≤ n, m ≤ 100). The next line contains n integers: a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ m).


-----Output-----

Print a single integer — the number of buses that is needed to transport all n groups to the dacha countryside.


-----Examples-----
Input
4 3
2 3 2 1

Output
3

Input
3 4
1 2 1

Output
1

Difficulty: EASY

Solutions:
(n, m) = map(int, input().split())
d = list(map(int, input().split()))
counter = 1
sum = 0
for i in range(n):
	sum += d[i]
	if sum > m:
		sum = d[i]
		counter += 1
print(counter)


(n, m) = map(int, input().split())
numppl = map(int, input().split())
(numbus, total) = (1, 0)
for i in numppl:
	total += i
	if total > m:
		numbus += 1
		total = i
print(numbus)


(n, m) = map(int, input().split())
qs = list(map(int, input().split()))
r = 0
f = m
for q in qs:
	if q <= f:
		f -= q
	else:
		r += 1
		f = m - q
if f < m:
	r += 1
print(r)


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


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
			else:
				break
	return ans

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


(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)


(n, m) = list(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) = [int(j) for j in input().split()]
nums = [int(j) for j in input().split()]
(bus, count) = (m, 1)
j = 0
while j < n:
	if bus - nums[j] >= 0:
		bus -= nums[j]
		j += 1
	else:
		bus = m
		count += 1
print(count)


T = 1
for _ in range(T):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	count = 0
	s = 0
	for num in a:
		if s + num <= m:
			s += num
		else:
			s = num
			count += 1
	count += 1
	print(count)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
res = 0
t = m
while len(l) > 0:
	if l[0] <= t:
		t = t - l.pop(0)
	else:
		res += 1
		t = m
print(res + 1)


(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)


from collections import deque
(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
(in_bus, left) = (0, 0)
groups = deque(a)
while groups:
	if in_bus + groups[0] <= m:
		in_bus += groups[0]
		if in_bus == m:
			left += 1
			in_bus = 0
		groups.popleft()
	else:
		left += 1
		in_bus = 0
if in_bus:
	left += 1
print(left)


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


(n, m) = map(int, input().split())
a = map(int, input().split())
ans = 1
res = m
for x in a:
	if res < x:
		res = m - x
		ans += 1
	else:
		res -= x
print(ans)


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


(a, b) = map(int, input().split())
ar = list(map(int, input().split()))
count = 1
sums = 0
for i in range(a):
	sums += ar[i]
	if sums > b:
		sums = ar[i]
		count += 1
print(count)


(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)


a = input().split()
b = input().split()
s = 0
i = 0
while i < len(b):
	capa = int(a[1])
	while capa >= 0 and i < len(b):
		capa = capa - int(b[i])
		i = i + 1
		if capa < 0:
			i = i - 1
			capa = 0
			break
	s = s + 1
print(s)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
ans = 1
space = m
for i in range(n):
	if space >= x[i]:
		space -= x[i]
	else:
		ans += 1
		space = m - x[i]
print(ans)


z = lambda : map(int, input().split())
(a, b) = z()
c = list(z())
s = i = 0
from math import *
while i < a:
	k = ceil(c[i] / b)
	l = k * b - c[i]
	i += 1
	s += k
	while i < a:
		if l >= c[i]:
			l -= c[i]
			i += 1
		else:
			break
print(s)


(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())
L = list(map(int, input().split()))
ans = 0
ind = 0
bus = 0
while ind < n:
	ans += 1
	while ind < n and bus + L[ind] <= m:
		bus += L[ind]
		ind += 1
	bus = 0
print(ans)


I = lambda : map(int, input().split())
(n, m) = I()
a = r = 0
for x in I():
	a += x
	if a >= m:
		r += 1
		a = [x, 0][a == m]
r += a > 0
print(r)


iData = list(map(int, str(input()).split(' ')))
(n, m) = (iData[0], iData[1])
a = list(map(int, str(input()).split(' ')))
(tmp, bus_count) = (0, 1)
for i in range(n):
	if tmp + a[i] <= m:
		tmp += a[i]
	else:
		bus_count += 1
		tmp = a[i]
print(bus_count)


(N, M) = map(int, input().split())
Queue = list(map(int, input().split()))
(Entered, Number, i) = (0, 0, 0)
while i < N:
	Entered += Queue[i]
	if Entered > M:
		(Number, Entered, i) = (Number + 1, 0, i - 1)
	i += 1
print(Number + 1)


(n, m) = input().split(' ')
a = input().split(' ')
count = 1
n = int(n)
m = int(m)
temp = m
for i in range(n):
	a[i] = int(a[i])
for i in range(n):
	if a[i] <= temp:
		temp -= a[i]
	else:
		temp = m - a[i]
		count += 1
print(count)


from sys import stdin
(n, m) = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
c = 0
i = 0
while i < n:
	t = m
	t -= a[i]
	i += 1
	while t > 0 and i < n:
		if t < a[i]:
			break
		t -= a[i]
		i += 1
	c += 1
print(c)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ans = 1
cur = m
for i in range(n):
	if a[i] > cur:
		ans += 1
		cur = m - a[i]
	else:
		cur -= a[i]
print(ans)


(n, m) = map(int, input().split())
(b, c) = (0, 0)
for i in map(int, input().split()):
	if c + i <= m:
		c += i
	else:
		b += 1
		c = i
print(b + 1)


import sys
(n, m) = map(int, sys.stdin.readline().split())
an = list(map(int, sys.stdin.readline().split()))
ans = 1
left = 0
for i in range(n):
	if left + an[i] <= m:
		left += an[i]
	else:
		left = an[i]
		ans += 1
print(ans)


inp = input().split()
n = int(inp[0])
m = int(inp[1])
inp = input().split()
q = [int(i) for i in inp]
num = 0
sum = 0
i = 0
while i < n:
	if sum + q[i] <= m:
		sum += q[i]
		i += 1
	else:
		sum = 0
		num += 1
print(num + 1)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
k = 1
t = 0
for i in range(n):
	if t + l[i] > m:
		k = k + 1
		t = l[i]
	else:
		t = t + l[i]
print(k)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ans = 1
load = 0
for g in a:
	load += g
	if load > m:
		ans += 1
		load = g
print(ans)


(n, m) = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
ans = 0
free = 0
for x in l:
	if free >= x:
		free -= x
	else:
		ans += 1
		free = m - x
print(ans)


(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)


(n, m) = map(int, input().split())
l_s = list(map(int, input().split()))
c_p = m
t = 0
for s in l_s:
	if c_p + s > m:
		t += 1
		c_p = s
	else:
		c_p += s
print(t)


(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)


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


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
ans = 1
lim = m
for x in l:
	if x <= lim:
		lim -= x
	else:
		lim = m - x
		ans = ans + 1
print(ans)


(n, m) = [int(c) for c in input().split()]
a = [int(c) for c in input().split()]
res = 0
current_sum = 0
while len(a) > 0:
	val = a.pop()
	if current_sum + val <= m:
		current_sum = current_sum + val
	else:
		current_sum = val
		res += 1
if current_sum != 0:
	res += 1
print(res)


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)


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


(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)


n_m = input().split()
ai = input().split()
res = 0
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 = int(ai[i])
if sum != 0:
	res += 1
print(res)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
count = 0
current = 0
x = 0
for b in a:
	if m - current >= b:
		current += b
	else:
		count += 1
		current = b
	x += 1
print(count + 1)


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


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
k = 0
ans = 1
for x in l:
	if k + x <= m:
		k += x
	else:
		k = x
		ans += 1
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))


while True:
	try:
		(n, m) = list(map(int, input().split()))
		A = list(map(int, input().split()))
		(ans, people) = (1, 0)
		for i in range(n):
			if people + A[i] <= m:
				people += A[i]
			else:
				ans += 1
				people = A[i]
		print(ans)
	except EOFError:
		break


(n, m) = list(map(int, input().split()))
p = list(map(int, input().split()))
bn = 0
ib = 0
for i in p:
	if ib + i > m:
		ib = i
		bn += 1
	else:
		ib += i
if ib > 0:
	bn += 1
print(bn)


import math
a = list(map(int, input().split()))
people = list(map(int, input().split()))
total_group = a[0]
seat_bus = a[1]
max_bus = total_group * seat_bus
check = 0
loop = math.ceil(total_group)
skip = False
rem = 0
temp = people[0]
prev = 0
cookies = 0
for i in range(0, loop - 1):
	if temp + people[i + 1] <= seat_bus:
		skip = False
	if people[i] + people[i + 1] <= seat_bus and skip == False:
		temp = people[i] + people[i + 1]
		people[i + 1] = temp
		cookies += 1
	else:
		cookies = 0
		check += 1
last = people[-1]
if last <= seat_bus and skip == False:
	check += 1
print(check)


(n, m) = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
ans = 1
tmp = 0
for i in range(n):
	if tmp + p[i] <= m:
		tmp += p[i]
	else:
		tmp = p[i]
		ans += 1
print(ans)


((n, m), a, b, c) = (list(map(int, input().split())), list(map(int, input().split())), 0, 0)
a.append(m + 1)
for i in range(len(a) - 1):
	if b + a[i] <= m and b + a[i] + a[i + 1] > m:
		b = 0
		c = c + 1
	else:
		b = b + a[i]
print(c)


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
flag = True
i = 0
count = 0
while i < n:
	sumb = 0
	while sumb <= m and i < n:
		sumb += a[i]
		i += 1
	if sumb > m:
		i -= 1
		sumb -= a[i]
	count += 1
print(count)


from math import ceil
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
i = 0
t = 0
while i < n:
	s = m
	while i < n:
		s = s - l[i]
		if s >= 0:
			i = i + 1
		else:
			break
	t = t + 1
print(t)


(n, m) = [int(i) for i in input().split()]
mas = [int(i) for i in input().split()]
send = 0
cou = 0
for i in range(n):
	if mas[i] + cou < m:
		cou += mas[i]
	elif mas[i] + cou == m:
		send += 1
		cou = 0
	else:
		send += 1
		cou = mas[i]
if cou != 0:
	send += 1
print(send)


import sys

def minp():
	return sys.stdin.readline().strip()
(n, m) = map(int, minp().split())
r = 0
c = m
for i in map(int, minp().split()):
	if c + i > m:
		c = i
		r += 1
	else:
		c += i
print(r)


class CodeforcesTask435ASolution:

	def __init__(self):
		self.result = ''
		self.n_m = []
		self.groups = []

	def read_input(self):
		self.n_m = [int(x) for x in input().split(' ')]
		self.groups = [int(x) for x in input().split(' ')]

	def process_task(self):
		buses = 1
		bus = 0
		while self.groups:
			if bus + self.groups[0] <= self.n_m[1]:
				bus += self.groups[0]
				self.groups = self.groups[1:]
			else:
				bus = 0
				buses += 1
		self.result = str(buses)

	def get_result(self):
		return self.result
Solution = CodeforcesTask435ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


(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)


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


3
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
	elif group + currentBusFilling != m:
		nbrOfBusses += 1
		currentBusFilling = group
	else:
		nbrOfBusses += 1
		currentBusFilling = 0
if currentBusFilling == 0:
	print(nbrOfBusses)
else:
	print(nbrOfBusses + 1)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
(x, y, i) = (0, 0, 0)
while i < n:
	x = x + l[i]
	if x > m:
		(y, x, i) = (y + 1, 0, i - 1)
	i = i + 1
print(y + 1)


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


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
i = 0
d = 0
k = 0
while i != n:
	if k < a[i]:
		d += 1
		k = m
	k -= a[i]
	i += 1
print(d)


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


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
i = 0
k = m
cnt = 0
while i < n:
	if a[i] <= k:
		k -= a[i]
		i += 1
		continue
	else:
		k = m
		cnt += 1
print(cnt + 1)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
x = count = 0
while x < n:
	bus = 0
	while bus <= m and x < n:
		if m - bus >= l[x]:
			bus += l[x]
			x += 1
		else:
			break
	count += 1
print(count)


w = list(map(int, input().split()))
n = w[0]
m = w[1]
pep = list(map(int, input().split()))
bus = 1
bus_cap = 0
i = 0
while i < n:
	if bus_cap + pep[i] > m:
		bus += 1
		bus_cap = pep[i]
	else:
		bus_cap += pep[i]
	i += 1
print(bus)


(n, m) = [int(x) for x in input().split()]
groups = [int(x) for x in input().split()]
total = 1
occupied = 0
for i in groups:
	if occupied + i <= m:
		occupied += i
	else:
		total += 1
		occupied = i
print(total)


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


(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())
k = list(map(int, input().split()))
x = m
buses = 1
i = 0
while i < n:
	ppl = k[i]
	if ppl > x:
		buses += 1
		x = m
	elif ppl == x:
		i += 1
		x = m
		if i != n:
			buses += 1
	else:
		x -= ppl
		i += 1
print(buses)


z = [int(n) for n in input().split()]
s = [int(n) for n in input().split()]
k = z[1]
l = 0
m = 0
for n in s:
	if n + m > k:
		m = n
		l += 1
	else:
		m += n
print(l + 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
		else:
			t += c
	return r
print(main())


def f(a, b, c):
	if not c:
		return 0 if a == b else 1
	if c[0] > a:
		return 1 + f(b, b, c)
	return f(a - c[0], b, c[1:])
a = int(input().split()[1])
b = list(map(int, input().split()))
print(f(a, a, b))


def solve(n, m, arr):
	count = 0
	cap = 0
	for i in arr:
		if cap + i <= m:
			cap += i
		else:
			count += 1
			cap = i
	return count + 1

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


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
c = 1
temp = 0
for i in a:
	if temp + i <= m:
		temp += i
	else:
		temp = i
		c += 1
print(c)


(a, b) = [int(i) for i in input().split()]
s = [int(i) for i in input().split()]
m = 1
c = b
for i in range(a):
	if s[i] > c:
		m = m + 1
		c = b - s[i]
	else:
		c = c - s[i]
print(m)


(N, M) = map(int, input().split())
Queue = list(map(int, input().split()))
Cur = 0
Ans = 1
for Bus in Queue:
	if Cur + Bus <= M:
		Cur += Bus
	else:
		Ans += 1
		Cur = Bus
print(Ans)


(n, m) = list(map(int, input().split()))
groups = list(map(int, input().split()))
temp = m
buses = 1
for i in groups:
	if i <= temp:
		temp -= i
	else:
		temp = m - i
		buses += 1
print(buses)


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) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
i = 0
cnt = 0
while i < n:
	cur = m
	while i < n and a[i] <= cur:
		cur -= a[i]
		i += 1
	cnt += 1
print(cnt)


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())
an = list(map(int, input().split()))
avtobus = 0
m2 = m
for grupp in an:
	if m2 >= grupp:
		m2 -= grupp
	else:
		m2 = m - grupp
		avtobus += 1
print(avtobus + 1)


(nb_groups, max_ride) = [int(x) for x in input().split()]
groups = [int(x) for x in input().split()]
need = 0
while groups:
	curr = max_ride
	while groups and curr >= groups[0]:
		curr -= groups.pop(0)
	need += 1
print(need)


(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.reverse()
ans = 0
while a:
	tmp = m
	while a and tmp >= a[-1]:
		tmp -= a.pop()
	ans += 1
print(ans)


(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)


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)


(group, capacity) = input().split()
(group, capacity) = (int(group), int(capacity))
groups = input().split()
(oldcapacity, ride_ons, bus, i) = (capacity, 0, 0, 0)
while i < group:
	cgroup = int(groups[i])
	if cgroup > capacity:
		bus = 0
		break
	if cgroup == oldcapacity:
		oldcapacity = capacity
		i = i + 1
		bus = bus + 1
	elif cgroup < oldcapacity and i != group - 1:
		oldcapacity = oldcapacity - cgroup
		i = i + 1
	elif cgroup < oldcapacity and i == group - 1:
		bus = bus + 1
		break
	else:
		bus = bus + 1
		oldcapacity = capacity
print(bus)


def main():
	linea = [int(x) for x in input().strip().split()]
	n = linea[0]
	m = linea[1]
	suma = 0
	linea = [int(x) for x in input().strip().split()]
	resp = 1
	for i in range(n):
		if suma + linea[i] <= m:
			suma += linea[i]
		else:
			resp += 1
			suma = linea[i]
	print(resp)
main()


l = list(map(int, input().split()))
m = list(map(int, input().split()))
a = l[1]
i = 0
b = 0
c = 1
sum = 0
while i < len(m):
	if m[i] <= a:
		b += 1
		sum += m[i]
		while i + c < len(m):
			if sum + m[i + c] <= a:
				sum += m[i + c]
				c += 1
			else:
				break
	i += c
	c = 1
	sum = 0
print(b)


import sys
input = sys.stdin.buffer.readline
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
s = 0
ans = 0
for i in range(n):
	s += arr[i]
	if s > m:
		ans += 1
		s = arr[i]
if s > 0:
	print(ans + 1)
else:
	print(ans)


import sys

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

def iinput():
	return int(input())

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

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
(n, m) = rinput()
a = list(map(int, input().split()))
bus = 1
rem = m
for i in range(n):
	if rem >= a[i]:
		rem -= a[i]
	else:
		bus += 1
		rem = m - a[i]
print(bus)


import math
s = input()
s = s.split()
n = int(s[0])
m = int(s[1])
l = input()
l = l.split()
t = 0
p = []
while t < n:
	p.append(int(l[t]))
	t += 1
i = 0
k = 0
while i < n:
	if p[i] > m:
		k += 1
		p[i] -= m
		continue
	if p[i] <= m:
		k += 1
		e = m - p[i]
		i += 1
		while i < n and e >= p[i]:
			e -= p[i]
			i += 1
print(k)


(n, m) = map(int, input().split())
ans = list(map(int, input().split()))
c = 1
p = 0
for i in range(n):
	if p + ans[i] <= m:
		p += ans[i]
	else:
		c += 1
		p = ans[i]
print(c)


(n, m) = (int(i) for i in input().split())
bus = 0
bus_count = 0
for i in input().split():
	bus += int(i)
	previous = int(i)
	if bus > m:
		bus_count += 1
		bus = previous
print(bus_count + bool(bus))


import math
import os
import random
import re
import sys
import functools
from operator import itemgetter, attrgetter
from collections import Counter
Y = lambda : list(map(int, input().split()))
P = lambda : map(int, input().split())
N = lambda : int(input())
(n, m) = P()
a = Y()
(i, s, cnt) = (0, 0, 1)
while i < n:
	if s + a[i] <= m:
		s += a[i]
		i += 1
	else:
		cnt += 1
		s = 0
print(cnt)


import sys
(n, M) = map(int, input().split())
A = list(map(int, input().split()))
k = 0
m = M
i = 0
while i < n:
	while i < n and m >= A[i]:
		m -= A[i]
		i += 1
	else:
		k += 1
		m = M
print(k)


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))
main()


(n, m) = map(int, input().split())
daf = list(map(int, input().split()))
total = 1
cap = 0
for i in range(n):
	if daf[i] <= m - cap:
		cap += daf[i]
	else:
		total += 1
		cap = daf[i]
print(total)


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


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])


def solve():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	c = 1
	i = 0
	cap = 0
	while i < n:
		if cap + a[i] <= m:
			cap += a[i]
			i += 1
		else:
			c += 1
			cap = 0
	print(c)
try:
	solve()
except:
	pass


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ans = 1
avt = m
i = 0
while i < n:
	if a[i] <= avt:
		avt -= a[i]
		i += 1
	else:
		ans += 1
		avt = m
print(ans)


(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)


(n, m) = list(map(int, input().split()))
c = list(map(int, input().split()))
i = 0
while c:
	v = m
	k = 0
	Y = False
	while v > 0 and c and (not Y):
		if c[0] <= v:
			v -= c[0]
			c.remove(c[0])
		else:
			Y = True
	i += 1
print(i)


(n, m) = map(int, input().split())
cnt = 1
group = 0
for el in map(int, input().split()):
	if group + el > m:
		cnt += 1
		group = el
	else:
		group += el
print(cnt)


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)
solve()


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


import math

def main_function():
	(n, m) = [int(i) for i in input().split(' ')]
	groups = [int(i) for i in input().split(' ')]
	counter = 1
	current_bus = 0
	for i in groups:
		if current_bus + i <= m:
			current_bus += i
		else:
			counter += 1
			current_bus = i
	print(counter)
main_function()


(g, b) = map(int, input().split())
buses = 1
current = 0
for x in map(int, input().split()):
	if current + x > b:
		buses += 1
		current = x
	else:
		current += x
print(buses)


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
res = 1
space = m
for i in range(n):
	if space >= arr[i]:
		space -= arr[i]
	else:
		res += 1
		space = m - arr[i]
print(res)


x = input()
y = input()
y = y.split()
x = x.split()
x1 = int(x[0])
x2 = int(x[1])
for i in range(x1):
	y[i] = int(y[i])
f = 0
flag = 0
i = 0
while i < x1:
	if y[i] <= f:
		f = f - y[i]
		i += 1
	elif y[i] <= x2:
		flag += 1
		f = x2 - y[i]
		i += 1
	else:
		i += 1
print(flag)


(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)


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


(n, m) = map(int, input().split())
ans = 0
mylist = [int(x) for x in input().split()]
while mylist != []:
	u = m
	while True:
		if mylist != [] and u - mylist[0] >= 0:
			u -= mylist[0]
			mylist.pop(0)
		else:
			ans += 1
			break
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)


def count(arr: list, capacity):
	counter = 1
	i = 1
	sum = arr[0]
	while i < len(arr):
		if sum + arr[i] <= capacity:
			sum += arr[i]
		else:
			counter += 1
			sum = arr[i]
		i += 1
	return counter
k = list(map(int, input().split()))[1]
array = list(map(int, input().split()))
print(count(array, k))


(n, m) = tuple(map(int, input().split()))
a = list(map(int, input().split()))
i = 0
k = 0
ans = 0
while i < n:
	if k + a[i] <= m:
		k += a[i]
	else:
		k = a[i]
		ans += 1
	i += 1
if k:
	ans += 1
print(ans)


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 sum > m:
	sum = 0
	bus = bus + 1
	i -= 1
if flag == False:
	bus = bus + 1
print(bus)


(n, m) = tuple(map(int, str.split(input())))
a = tuple(map(int, str.split(input())))
cbus = 0
count = 0
for x in a:
	if cbus + x <= m:
		cbus += x
	else:
		cbus = x
		count += 1
if cbus:
	count += 1
print(count)


t = input().split()
n = int(t[0])
m = int(t[1])
del t
t = [int(x) for x in input().split()]
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(slon)


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


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
c = 0
i = 0
while i < n:
	p = m
	while p >= a[i]:
		p -= a[i]
		i += 1
		if i >= n:
			break
	c += 1
print(c)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
	for j in range(i + 1, n):
		if a[i] + a[j] <= m:
			a[i] += a[j]
			a[j] = 0
		else:
			break
a = [a[i] for i in range(n) if a[i] != 0]
print(len(a))


from sys import exit
(n, t) = input().split()
n = int(n)
t = int(t)
test_case = input()
a = []
for w in test_case.split():
	r = int(w)
	a.append(r)
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 os
import sys
from io import BytesIO, IOBase
_str = str
BUFSIZE = 8192

def str(x=b''):
	return x if type(x) is bytes else _str(x).encode()

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def inp():
	return sys.stdin.readline().rstrip()

def mpint():
	return map(int, inp().split(' '))

def itg():
	return int(inp())

def solve():
	(n, m) = mpint()
	ans = 1
	c = 0
	for a in mpint():
		c += a
		if c > m:
			ans += 1
			c = a
	return ans

def main():
	print(solve())
DEBUG = 0
URL = 'https://codeforces.com/contest/435/problem/A'
if DEBUG == 1:
	import requests
	from ACgenerator.Y_Test_Case_Runner import TestCaseRunner
	runner = TestCaseRunner(main, URL)
	inp = runner.input_stream
	print = runner.output_stream
	runner.checking()
elif DEBUG == 2:
	main()
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	main()


__author__ = 'DOAN Minh Quy'
(n, m) = map(int, input().split())
L = list(map(int, input().split()))
ans = 0
i = 0
bus = 0
while i < n:
	ans += 1
	while i < n and bus + L[i] <= m:
		bus += L[i]
		i += 1
	bus = 0
print(ans)


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]
		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)


row = input().split()
n = int(row[0])
m = int(row[1])
members = list(map(int, input().split()))
count = 0
sum = 0
for i in range(n):
	if sum + members[i] <= m:
		sum += members[i]
	else:
		count += 1
		sum = members[i]
if sum > 0:
	count += 1
print(count)


(n, m) = map(int, input().split())
groups = list(map(int, input().split()))
i = 0
count = []
if len(groups) == 1:
	count = [1]
else:
	while i + 1 < len(groups):
		temp = groups[i]
		i = i + 1
		while temp + groups[i] <= m and i < len(groups) - 1:
			temp = temp + groups[i]
			i = i + 1
		count.append(temp)
	if count[-1] + groups[-1] > m:
		count.append(5)
print(len(count))


(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)


import sys
(n, m) = map(int, sys.stdin.readline().split())
a = list(map(int, sys.stdin.readline().split()))
ans = 0
while a:
	s = 0
	for i in range(len(a)):
		s += a[i]
		if s > m:
			ans += 1
			a = a[i:]
			break
	else:
		ans += 1
		break
print(ans)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = 0
i = 0
while i < n:
	j = i
	k = 0
	while j < n and k + a[j] <= m:
		k += a[j]
		j += 1
	b += 1
	i = j
print(b)


from collections import deque, defaultdict, Counter
from itertools import product, groupby, permutations, combinations
from math import gcd, floor, inf
from bisect import bisect_right, bisect_left
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
avail = m
ans = 0
for group in arr:
	if group <= avail:
		avail -= group
	else:
		ans += 1
		avail = m - group
if avail != m:
	ans += 1
print(ans)


(n, m) = map(int, input().split())
groups = [int(c) for c in input().split()]
ans = 0
while sum(groups) > 0:
	cap = m
	for i in range(n):
		if groups[i] <= cap:
			cap -= groups[i]
			groups[i] = 0
		else:
			break
	ans += 1
print(ans)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
l = len(a)
c = 0
s = 0
i = 0
while i < l:
	s = a[i]
	c += 1
	while s <= m:
		i += 1
		if i < l:
			s += a[i]
		else:
			break
print(c)


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)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
(t1, c) = (0, 1)
for i in a:
	t1 += i
	if t1 > m:
		c += 1
		t1 = i
print(c)


(n, m) = map(int, input().split())
queue = list(map(int, input().split()))
sit = 0
ans = 0
for i in queue:
	if sit + i > m:
		ans += 1
		sit = i
	else:
		sit += i
if sit > 0:
	ans += 1
print(ans)


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


(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)


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())
a = [*map(int, input().split())]
c = 1
r = m
for x in a:
	if r < x:
		c += 1
		r = m
	r -= x
print(c)


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)


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


(n, m) = (int(x) for x in input().split())
(cur, val) = (0, 1)
for ai in (int(x) for x in input().split()):
	if cur + ai <= m:
		cur += ai
	else:
		cur = ai
		val += 1
print(val)


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


(groups, seats) = input().split()
(groups, seats) = (int(groups), int(seats))
numbers = list(map(int, input().split()))
count = 1
i = 0
rem = seats
while i < groups:
	if rem - numbers[i] >= 0:
		rem -= numbers[i]
		i += 1
	else:
		rem = seats
		count += 1
print(count)


(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
result = 0
cur = 0
for i in a:
	if i + cur > m:
		cur = i
		result += 1
	else:
		cur += i
if cur > 0:
	result += 1
print(result)


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
bus_counts = 0
bus_left_seats = m
for (i, ai) in enumerate(a):
	if bus_left_seats < ai:
		bus_counts += 1
		bus_left_seats = m
	bus_left_seats -= ai
if bus_left_seats != m:
	bus_counts += 1
print(bus_counts)


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
ans = 0
temp = m
for i in range(len(arr)):
	if temp >= arr[i]:
		temp -= arr[i]
	else:
		ans += 1
		temp = m
		temp -= arr[i]
print(ans + 1)


(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())
q = list(map(int, input().split()))
i = 0
nrb = 0
while i < n:
	cap = 0
	nrb += 1
	while i < n and cap + q[i] <= m:
		cap += q[i]
		i += 1
print(nrb)


(n, m) = map(int, input().split())
(buses, used_seats) = (1, 0)
for a in list(map(int, input().split())):
	used_seats += a
	if used_seats > m:
		(buses, used_seats) = (buses + 1, a)
print(buses)


(groups, capacity) = map(int, input().split())
buses = 1
members = list(map(int, input().split()))
new_capacity = capacity
i = 0
while i < groups:
	if members[i] <= new_capacity:
		new_capacity = new_capacity - members[i]
		i = i + 1
	else:
		buses = buses + 1
		new_capacity = capacity
print(buses)


(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)


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


from sys import stdin

def main():
	(n, m) = map(int, stdin.readline().strip().split())
	it = iter(map(int, stdin.readline().strip().split()))
	try:
		cnt = vol = 0
		while True:
			x = next(it)
			if vol < x:
				cnt += 1
				vol = m
			vol -= x
	except StopIteration:
		return cnt
print(main())


(n, m) = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]
t = ans = 0
for i in arr:
	if t + i <= m:
		t += i
	else:
		t = i
		ans += 1
print(ans + (t > 0))


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


string = input()
numbers = string.split()
a = int(numbers[1])
string = input()
numbers = list(map(int, string.split()))
n = 0
while len(numbers) != 0:
	b = 0
	for x in numbers[:]:
		b += x
		if b > a:
			break
		numbers.remove(x)
	n += 1
print(n)