Question
The Vending Machine's Exact Change

A vending machine dispenses change using a fixed set of M coin denominations, C_1, C_2, ..., C_M (the machine has an unlimited supply of each denomination). Given a target amount Amount that must be dispensed exactly, find the minimum number of coins needed to make up that exact amount.

If it is not possible to make the exact amount using any combination of the available denominations, report -1.

Input

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.

Output

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.

Example
Example 1:
Input
3 11

1 2 5
Output
3
Explanation
The amount 11 can be made using KaTeX can only parse string typed expression, using 3 coins, which is optimal.

Example 2:
Input
1 3

2
Output
-1
Explanation
With only 2-unit coins available, it is impossible to make an odd amount like 3 exactly.

Example 3:
Input
3 0

1 2 5
Output
0
Explanation
An amount of 0 requires no coins at all.

Online