A vending machine dispenses change using a fixed set of
If it is not possible to make the exact amount using any combination of the available denominations, report
The first line contains two integers KaTeX can only parse string typed expression and KaTeX can only parse string typed expression — the number of coin denominations and the target amount.
The second line contains KaTeX can only parse string typed expression integers KaTeX can only parse string typed expression — the available coin denominations.
Print a single integer — the minimum number of coins needed to make the exact target amount, or KaTeX can only parse string typed expression if it is impossible.
Input
3 11
1 2 5Output3ExplanationThe amount 11 can be made using KaTeX can only parse string typed expression, using 3 coins, which is optimal.
Example 2:
Input
1 3
2Output-1ExplanationWith only 2-unit coins available, it is impossible to make an odd amount like 3 exactly.
Example 3:
Input
3 0
1 2 5Output0ExplanationAn amount of 0 requires no coins at all.