~/algor $ cat problems/bit-qism-toplamlar
Subsets with sum S
Medium
1000 ms
128 MB
64%
$n$ positive integers $a_{1}, a_{2}, \ldots, a_{n}$ and an integer $S$ are given. Find how many subsets have the sum of their elements equal to exactly $S$. The sum of the empty set is $0$; elements with equal values at different positions are considered different.
Input
The first line contains two integers: $n$ and $S$. The second line contains $n$ positive integers $a_{i}$ separated by spaces.
Output
One integer — the number of subsets.
Note
$1 \le n \le 16$
$1 \le a_{i} \le 10^{6}$
$0 \le S \le 1.6 * 10^{7}$
Examples
Input #1
4 10 2 3 5 7
Output #1
2
Input #2
3 100 1 2 3
Output #2
0