#C6697. Minimum Trips

    ID: 50485 Type: Default 1000ms 256MiB

Minimum Trips

Minimum Trips

You are given a bus that can carry at most \(M\) passengers at a time and \(N\) bus stops. At each bus stop, a number of passengers are waiting to be picked up; the number of passengers at the \(i\)-th stop is given by \(P_i\). The bus collects passengers sequentially from the first bus stop to the last.

If collecting passengers from a bus stop would cause the total number onboard to exceed \(M\), the bus departs immediately carrying the current load, and then returns to pick up the remaining passengers starting at that stop.

Your task is to calculate the minimum number of trips required to pick up all passengers. If there are no passengers at all, the result should be \(0\).

inputFormat

The input consists of two lines.

The first line contains two integers \(N\) and \(M\), where \(N\) is the number of bus stops and \(M\) is the maximum number of passengers that the bus can carry on a single trip.

The second line contains \(N\) integers \(P_1, P_2, \ldots, P_N\) representing the number of passengers waiting at each bus stop.

outputFormat

Output a single integer representing the minimum number of trips required to pick up all passengers.

If there are no passengers, output 0.

## sample
5 4
1 2 3 4 5
4