A=A1∪A2∪A3∪…∪Am
|A|=∑mi=1|Ai|−∑i<j|Ai∩Aj|+∑i<j<k|Ai∩Aj∩Ak|+…+(−1)m−1∑|A1∩A2∩A3∩…∩Am|
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cctype>
#include <cstring>
#include <algorithm>
#ifndef WIN32
#define Auto "%lld"
#else
#define Auto "%I64d"
#endif
using namespace std;
#define ll long long
ll gcd(ll a, ll b) {
return (!b) ? (a) : (gcd(b, a % b));
}
int n, m;
int *arr;
ll res = 0;
inline void init() {
int bn;
scanf("%d%d", &bn, &m);
arr = new int[(bn + 1)];
for(int i = 1, x; i <= bn; i++) {
scanf("%d", &x);
if(x > 17)
arr[++n] = x;
}
}
void dfs(int dep, int flag, ll temp) {
if(temp > m) return;
if(dep == n + 1) {
if(temp > 1)
res += flag * (m / temp);
return;
}
int g = gcd(temp, arr[dep]);
dfs(dep + 1, flag, temp);
dfs(dep + 1, flag * -1, temp / g * arr[dep]);
}
inline void solve() {
res = (m >= 17 && n) ? (1) : (0);
m -= 17;
dfs(1, -1, 1);
printf(Auto, res);
}
int main() {
init();
solve();
return 0;
}