atcoder#ABC182F. [ABC182F] Valid payments

[ABC182F] Valid payments

Score : 600600 points

Problem Statement

In Republic of AtCoder, NN kinds of coins are used: A1A_1-yen, A2A_2-yen, A3A_3-yen, \dots, ANA_N-yen coins. Here, A1=1A_1 = 1 holds, and for each ii such that 1i<N1 \le i \lt N, Ai<Ai+1A_i \lt A_{i + 1} holds and Ai+1A_{i + 1} is a multiple of AiA_i.

At some shop in this country, Lunlun the dog bought an XX-yen product by giving y (X)y\ (\ge X) yen to the clerk and receiving the change of yXy - X yen from the clerk. (The change may have been 00 yen.) Here, both Lunlun and the clerk used the minimum number of coins needed to represent those amounts of money. Additionally, the clerk did not return any kind of coins that Lunlun gave him.

Given XX, find the number of possible values for yy.

Constraints

  • 1N501 \le N \le 50
  • $1 = A_1 \lt A_2 \lt A_3 \lt \dots \lt A_N \le 10^{15}$
  • Ai+1A_{i + 1} is a multiple of AiA_i. (1i<N)(1 \le i \lt N)
  • 1X10151 \le X \le 10^{15}
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN XX

$A_1 \hspace{7pt} A_2 \hspace{7pt} A_3 \hspace{5pt} \dots\ \hspace{5pt} A_N$

Output

Print the number of possible values for yy.

3 9
1 5 10
3

yy can be 99, 1010, or 1414. For example, when y=14y = 14, Lunlun gives one 1010-yen coin and four 11-yen coins, and the clerk returns one 55-yen coin. Here, the clerk is not returning any kind of coins that Lunlun gives him, satisfying the requirement.

5 198
1 5 10 50 100
5

yy can be 198198, 200200, 203203, 208208, or 248248.

4 44
1 4 20 100
4

yy can be 4444, 6060, 100100, or 104104.

9 11837029798
1 942454037 2827362111 19791534777 257289952101 771869856303 3859349281515 30874794252120 216123559764840
21