Hide

Problem C
Taking Out the Trash

Peter has way too much trash and he needs to take it all out.

Specifically, there are n bags of trash each with a specific weight. Peter can hold either one or two bags of trash per trip, and he can carry a maximum total of m milligrams of trash in a single trip. What is the minimum number of trips Peter needs to take to take out all the trash?

Input

The input starts with two integers n (1n5105) and m (1m109), the number of bags of trash and the maximum weight of trash Peter can carry.

The next line contains n integers, wi (1wim), the weight of each bag of trash in milligrams.

Output

Output the minimum number of trips Peter needs to make to take out all the trash.

Sample Input 1 Sample Output 1
4 1000
100 900 200 900
3
Sample Input 2 Sample Output 2
4 10
1 2 3 4
2
Hide

Please log in to submit a solution to this problem

Log in