There are $N$ coin denominations (arbitrary positive integers). Using an unlimited supply of each, print the minimum number of coins needed to make exactly $K$, or -1 if it is impossible.
Input
Line 1: $N$ and $K$ ($1 \le N \le 100$, $1 \le K \le 10000$). Line 2: $N$ denominations ($1 \le A_i \le 10000$).
Output
Print the minimum number of coins, or -1.
Example 1
Input
3 6 1 3 4
Output
2
Example 2
Input
2 7 3 5
Output
-1
Discussion
Threads about this problem. Spoilers are collapsed; wrap hints in
||double bars||.No discussion yet. Start a thread if something here needs explaining.