OJOnline Judge
HomeProblemsSubmissionsRankingAdmin
Sign in
← Problems/MC1

MC1Minimizing Coins

Easystdio★ 1000dynamic programminggreedy
Time
1000 ms
Memory
256 MB
I/O
stdio
Tests
19 (18 hidden)
Solved
2

Minimizing Coins

You have an unlimited supply of coins in nnn distinct denominations. Find the minimum number of coins needed to produce the sum xxx exactly.

Input

The first line contains two integers nnn and xxx: the number of denominations and the target sum. The second line contains nnn distinct integers c1,c2,…,cnc_1, c_2, \ldots, c_nc1​,c: the coin values.

Output

Print the minimum number of coins needed to produce xxx. If the sum cannot be produced, print −1-1−1.

Constraints

1≤n≤1001 \le n \le 1001≤n≤100

1≤x≤1061 \le x \le 10^61≤x≤106

1≤ci≤1061 \le c_i \le 10^61≤ci​≤106

Example

Input:

text
3 11
1 5 7

Output:

text
3

The sum 111111 can be produced as 5+5+15 + 5 + 15+5+1, using three coins. It cannot be produced with fewer coins.

Allowed languages

Python, C++

Samples

Sample 1

Input

3 11
1 5 7

Output

3

The sum 11 can be produced as 5 + 5 + 1, using three coins.

Log in to submit a solution.

Source codeType here, or drop a file onto it
Loading editor...
2​
,
…
,
cn​