Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!
ALGOR Contest: Round #2
Problem F · 250 points · ICPC rules

~/algor $ cat contests/round-2/F

F. Coins

2000 ms 64 MB

There are coins of n different denominations, and any number of coins of each denomination may be taken. What is the smallest number of coins needed to pay the sum S? If exactly S cannot be paid, print −1. (If S = 0, the answer is 0.)

Coins: paying S = 6 takes 2 coins — 3 + 3

Input

The first line contains n and S. The second line contains n distinct integers — the coin denominations.

Output

One integer — the smallest number of coins or −1.

Note

1 ≤ n ≤ 100; 0 ≤ S ≤ 100 000; 1 ≤ coin denomination ≤ 100 000

Examples

Input #1
3 6
1 3 4
Output #1
2
Input #2
1 3
2
Output #2
-1

Sign in to submit a solution

Signing up is free and takes a minute.