Weighing of Souls
In the courts of ancient Egypt, the god Anubis weighs the souls of the dead in a long ceremonial line. There are souls waiting to be judged, and each soul has a known weight of virtue in grams. Anubis must choose exactly
grams for a rite of passage. Because the procession is sacred, he may only select a contiguous group of souls and will not rearrange their order.
Given the weights of the souls in order, find out how many ways Anubis can choose a contiguous group of souls whose total weight is exactly .
Input
The first line will contain two integers, - the number of souls in the procession (
), and
- the target weight (
)
There will then be integers, where
represents the weight of the
cow (
)
Output
Output the number of different ways Anubis can get exactly grams from the souls.
Example
Input
5 300
100 200 150 50 100
Output
2
Explanation: Indices [0, 1] sum to 300 (100 + 200), and indices [2, 4] sum to 300 (150 + 50 + 100)
Comments