#ABC231E. [ABC231E] Minimal payments

[ABC231E] Minimal payments

Score : 500500 points

Problem Statement

There are NN kinds of coins used in the Kingdom of Atcoder: A1A_1-yen, A2A_2-yen, \ldots, ANA_N-yen coins. Here, 1=A1<<AN1=A_1 < \ldots < A_N holds, and Ai+1A_{i+1} is a multiple of AiA_i for every 1iN11\leq i \leq N-1.

When paying for a product worth XX yen using just these coins, what is the minimum total number of coins used in payment and returned as change?

Accurately, when YY is an integer at least XX, find the minimum sum of the number of coins needed to represent exactly YY yen and the number of coins needed to represent exactly YXY-X yen.

Constraints

  • All values in input are integers.
  • 1N601 \leq N \leq 60
  • $1=A_1 < \ldots
  • Ai+1A_{i+1} is a multiple of AiA_i for every 1iN11\leq i \leq N-1.
  • 1X10181\leq X \leq 10^{18}

Input

Input is given from Standard Input in the following format:

NN XX

A1A_1 \ldots ANA_N

Output

Print the answer.

3 87
1 10 100
5

If we pay with one 100100-yen coin and receive one 1010-yen coin and three 11-yen coins as the change, the total number of coins will be 55.

2 49
1 7
7

It is optimal to pay with seven 77-yen coins.

10 123456789012345678
1 100 10000 1000000 100000000 10000000000 1000000000000 100000000000000 10000000000000000 1000000000000000000
233