# 3번 다리를 지나는 트럭

def solution(bridge_length, weight, truck_weights):
    answer = 0

    q = [0] * bridge_length

    while q:
        answer +=1
        q.pop(0)
        if truck_weights:
            if sum(q) + truck_weights[0] <= weight:
                q.append(truck_weights.pop(0))
            else:
                q.append(0)


    return answer




b = 2
w = 10
t = [7,4,5,6]

print(solution(b,w,t))