Problem:
Score : 400 points

Problem Statement

Given are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.

Let a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \leq k \leq N):

There exists a non-negative integer p such that X= a_k \times (p+0.5).

Find the number of semi-common multiples of A among the integers between 1 and M (inclusive).

Constraints

1 \leq N \leq 10^5

1 \leq M \leq 10^9

2 \leq a_i \leq 10^9

a_i is an even number.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
a_1 a_2 ... a_N

Output

Print the number of semi-common multiples of A among the integers between 1 and M (inclusive).

Sample Input 1

2 50
6 10

Sample Output 1

2

15 = 6 \times 2.5

15 = 10 \times 1.5

45 = 6 \times 7.5

45 = 10 \times 4.5

Thus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.

Sample Input 2

3 100
14 22 40

Sample Output 2

0

The answer can be 0.

Sample Input 3

5 1000000000
6 6 2 6 2

Sample Output 3

166666667

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 30, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  ;
  cin >> N >> M;
  va.resize(N);
  rep(i, 0, N - 1) { cin >> va[i]; }
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return (a * b) / gcd(a, b); }

int div2count(int n) {
  int ret = 0;
  if (!n) return 0;
  for (;;) {
    if (n & 1) {
      return ret;
    }
    ret++;
    n >>= 1;
  }
}
void solve() {
  ;
  ;
  // auto gcd = [](int a, int b) { return b ? gcd(a % b, a) : a; };
  // auto lcm = [](int a, int b) { return a * b / gcd(a, b); };
  each(x, va) {
    x >>= 1;  // ぐうすうなので
  }
  //

  int cnt2 = div2count(va[0]);
  for (auto x : va) {
    if (cnt2 != div2count(x)) {
      cout << 0 << endl;
      return;
    }
  }

  int al = 1;
  rep(i, 0, N - 1) {
    al = lcm(al, va[i]);
    // debug2(i, al);
  }
  if (al > M) {
    cout << 0;
    return;
  }
  // if (M / al % 2 == 1) {
  //   cout << M / al / 2 + 1 << endl;
  //   return;
  // } else {
  //   cout << M / al / 2 << endl;
  // }

  // //  al = accumulate(all(va), 1, lcm);
  // auto isOK = [&](int mid, int key) {
  //   return al * mid + al / 2 <= M;  // for now
  // };
  // auto binary_search = [&](int key) {
  //   int ng = INF;
  //   int ok = -1;
  //   while (abs(ok - ng) > 1) {
  //     int mid = (ok + ng) >> 1;
  //     (isOK(mid, key) ? ok : ng) = mid;
  //   }
  //   return ok;
  // };
  // int kk = binary_search(0);
  // cout << kk + 1 << endl;
  M += al;
  cout << M / 2 / al << endl;
}
signed main() {
  input();
  solve();
  return 0;
}