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: interview

Starter code:

Solutions:
n,m=list(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)


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)


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

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)

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 = list(map(int,input().split()))
x = 1
c = 0
for i in a:
    if c+i <= m:
        c+=i
    else:
        c = i
        x+=1
print(x)

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)

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


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)


import sys
#sys.stdin = open('input.txt', 'r')

n, M = list(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]
		#print(k,m)
		i += 1
		#k += 1
	else:
		k += 1
		m = M
print(k)








n, m = list(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)


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


n, m = list(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), 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=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)

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

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

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)


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

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