AtCoder Beginner Contest 150 - Semi Common Multiple

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-----
2 50
6 10

-----Sample Output-----
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.

Difficulty: MEDIUM

Starter code:

Solutions:
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
g = A[-1]
l = A[-1]
import fractions
for i in range(2, N + 1):
	a = A[-i]
	g = fractions.gcd(l, a)
	l = l * a // g
	if l // 2 > M:
		print(0)
		quit()
b = l // 2
f = (M - b) // l + 1
for i in range(N):
	if b % A[i] == 0:
		f = 0
		break
if M < l // 2:
	ans = 0
else:
	ans = f
print(ans)


import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
input = sys.stdin.readline

def RD():
	return input().rstrip()

def F():
	return float(input().rstrip())

def I():
	return int(input().rstrip())

def MI():
	return map(int, input().split())

def MF():
	return map(float, input().split())

def LI():
	return list(map(int, input().split()))

def TI():
	return tuple(map(int, input().split()))

def LF():
	return list(map(float, input().split()))

def Init(H, W, num):
	return [[num for i in range(W)] for j in range(H)]

def main():
	(N, M) = MI()
	L = LI()
	L = [i // 2 for i in L]
	past = L[0]
	for i in L:
		past = past // math.gcd(i, past) * i
		if past > M or past // i % 2 == 0:
			print(0)
			return
	temp = M // past
	ans = (temp + 1) // 2
	print(ans)

def __starting_point():
	main()
__starting_point()


import math
from functools import reduce
(N, M) = list(map(int, input().split()))
A = [int(x) // 2 for x in input().split()]

def lcm_base(x, y):
	return x * y // math.gcd(x, y)

def lcm(*numbers):
	return reduce(lcm_base, numbers, 1)
LCM = lcm(*A)
for a in A:
	if LCM // a % 2 == 0:
		print(0)
		break
else:
	print((M // LCM + 1) // 2)


import math
from functools import reduce

def lcm_base(x, y):
	return x * y // math.gcd(x, y)

def lcm(*numbers):
	return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
	return reduce(lcm_base, numbers, 1)

def my_round(val, digit=0):
	p = 10 ** digit
	return (val * p * 2 + 1) // 2 / p
(n, m) = list(map(int, input().split()))
a_pr = [i // 2 for i in list(map(int, input().split()))]
lcm_ = lcm_list(a_pr)
(res, div2) = (0, None)
for ai in a_pr:
	cnt = 0
	while ai % 2 == 0:
		ai //= 2
		cnt += 1
	if div2 is None:
		div2 = cnt
	elif cnt != div2:
		print(0)
		return
print(int(my_round(m // lcm_ / 2)))


from math import gcd, ceil

def lcm(a, b):
	return a * b // gcd(a, b)
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
	a[i] = a[i] // 2
lcm_v = a[0]
for i in range(1, n):
	lcm_v = lcm(lcm_v, a[i])
ok = True
for aa in a:
	if lcm_v // aa % 2 != 1:
		ok = False
		break
ans = 0
if ok:
	ans = (m // lcm_v + 1) // 2
print(ans)


import fractions
from functools import reduce

def lcm1(x, y):
	return x * y // fractions.gcd(x, y)

def lcm2(*numbers):
	return reduce(lcm1, numbers, 1)
(n, m) = map(int, input().split())
a = set(map(lambda x: int(x) // 2, input().split()))
l = lcm2(*a)
for i in a:
	if l // i % 2 == 0:
		print(0)
		exit()
print((m // l + 1) // 2)


import math
import fractions
from functools import reduce
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
a = [t // 2 for t in a]

def lcm_base(x, y):
	return x * y // fractions.gcd(x, y)

def lcm_list(numbers):
	return reduce(lcm_base, numbers, 1)

def num_dev2(x):
	return bin(x)[::-1].find('1')
lcm = lcm_list(a)
q = m // lcm
count = 0
dev2 = num_dev2(a[0])
for i in range(1, n):
	if dev2 != num_dev2(a[i]):
		count += 1
		break
if count != 0:
	print(0)
else:
	print(math.ceil(q / 2))


from math import gcd
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
memo = {}

def lcm(a, b):
	return a // gcd(a, b) * b
b = 1
for a in A:
	b = lcm(a // 2, b)
	if b > M:
		break
if any([2 * b // a % 2 == 0 for a in A]):
	print(0)
else:
	ans = M // b
	print(ans - ans // 2)


import queue
import numpy as np
import math
(N, M) = map(int, input().split())
a2 = list(map(int, input().split()))
a = []
for i in a2:
	a.append(i // 2)
lcm = a[0]
for i in a:
	lcm *= i // math.gcd(lcm, i)
hasAns = True
for i in a:
	if lcm // i % 2 == 0:
		hasAns = False
		break
ans = 0
if hasAns:
	ans = (M // lcm + 1) // 2
print(ans)


import fractions

def lcm(x, y):
	return x * y // fractions.gcd(x, y)
(N, M) = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
a = 1
MOD = 10 ** 9 + 7
cnt = 10 ** 9
l = 0
for i in A:
	i = i // 2
	a = lcm(a, i)
for i in A:
	cnt1 = 0
	b = i // 2
	if b % 2 == 0:
		while b % 2 == 0:
			b = b / 2
			cnt1 += 1
	if cnt == 10 ** 9:
		cnt = cnt1
	elif cnt != cnt1:
		print(0)
		exit()
print((M // a + 2 - 1) // 2)


import math

def LCM(a, b):
	g = math.gcd(a, b)
	return a * b // g
(N, M) = list(map(int, input().split()))
A = list(map(int, input().split()))
A = list(set(A))
N = len(A)
a0 = A[0]
div = 1
while a0 % 2 == 0:
	div *= 2
	a0 //= 2
for i in range(1, N):
	a = A[i] % div
	b = A[i] // div
	if b % 2 == 0 or a != 0:
		print(0)
		return
for i in range(N):
	A[i] //= 2
if N > 1:
	lcm = LCM(A[0], A[1])
	for i in range(2, N):
		lcm = LCM(lcm, A[i])
if N == 1:
	lcm = A[0]
ans = M // lcm
if ans % 2 == 1:
	print(ans // 2 + 1)
else:
	print(ans // 2)


from math import gcd

def readinput():
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	return (n, m, a)

def lcm(a, b):
	return a * b // gcd(a, b)

def main(n, m, a):
	x = a[0] // 2
	for i in range(1, n):
		x = lcm(x, a[i] // 2)
	gusubai = False
	kisubai = False
	for i in range(n):
		if x % a[i] != 0:
			gusubai = True
		else:
			kisubai = True
	y = m // x
	if gusubai and (not kisubai):
		ans = y // 2 + y % 2
	elif gusubai and kisubai:
		ans = 0
	else:
		ans = y
	return ans

def __starting_point():
	(n, m, a) = readinput()
	ans = main(n, m, a)
	print(ans)
__starting_point()


from functools import reduce

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return abs(a)

def lcm(a, b):
	return a * b // gcd(a, b)
(N, M) = map(int, input().split())
A = [int(a) // 2 for a in input().split()]
B = [a & -a for a in A]
if min(B) != max(B):
	print(0)
else:
	l = reduce(lcm, A)
	print(M // l - M // l // 2)


from sys import exit
from fractions import gcd
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
a = A[0]
n = 1
while a % 2 == 0:
	n *= 2
	a //= 2
lcm = 1
for a in A:
	if a % n != 0 or a % (2 * n) == 0:
		print(0)
		exit()
	lcm = lcm * a // gcd(lcm, a)
	if lcm // 2 > M:
		print(0)
		exit()
print((M - lcm // 2) // lcm + 1)


import sys
import numpy as np

def input():
	return sys.stdin.readline().rstrip()

def kosuu(x):
	re = [0, 0]
	while x % 2 == 0:
		x = x // 2
		re[1] += 1
	re[0] = x
	return re

def main():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	li = [kosuu(a[0])[0]]
	hantei = kosuu(a[0])[1]
	for i in a[1:]:
		hantei2 = kosuu(i)
		if hantei2[1] != hantei:
			print(0)
			break
		else:
			li.append(hantei2[0])
	else:
		lc = np.lcm.reduce(li)
		print((m // (lc * 2 ** (hantei - 1)) + 1) // 2)

def __starting_point():
	main()
__starting_point()


import sys, math
r = sys.stdin.readline

def gcd(a, b):
	(a, b) = (max(a, b), min(a, b))
	while b > 0:
		(a, b) = (b, a % b)
	return a

def lcm(arr):
	while len(arr) != 1:
		a = arr.pop()
		b = arr.pop()
		c = gcd(a, b)
		arr.insert(0, int(a * b / c))
	return arr[0]

def cnt2(num):
	cnt = 0
	while num % 2 == 0:
		num /= 2
		cnt += 1
	return cnt
(N, M) = list(map(int, r().split()))
seq = list(map(int, r().split()))
seq = list(set(seq))
tmp = cnt2(seq[0])
for num in seq:
	if tmp != cnt2(num):
		print(0)
		return
T = lcm(list([x // 2 for x in seq]))
if T > M:
	print(0)
	return
print(math.floor(M // T / 2 + 0.5))


import fractions
s = list(map(int, input().split()))
t = [int(i) // 2 for i in input().split()]
ans = t[0]
for i in range(1, s[0]):
	ans = ans * t[i] // fractions.gcd(ans, t[i])
	if ans > 10 ** 10:
		print(0)
		exit()
for j in t:
	if ans // j % 2 == 0:
		print(0)
		exit()
if ans <= s[1]:
	print(int((s[1] // ans + 1) // 2))
else:
	print(0)


from fractions import gcd

def lcm(a, b):
	return a * b // gcd(a, b)
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ans = 1
for i in a:
	ans = lcm(ans, i)
for i in a:
	if ans // i % 2 == 0:
		print(0)
		return
print((m // (ans // 2) + 1) // 2)


import math
import numpy as np
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
c = 1
test = A[0]
l = 0
while test % 2 == 0:
	test = test // 2
	c *= 2
for i in np.arange(N - 1):
	if A[i + 1] % c != 0:
		print(0)
		l = 1
		break
	elif A[i + 1] % (c * 2) == 0:
		print(0)
		l = 1
		break
	else:
		k = A[i + 1] // c
		test = test * k // math.gcd(test, k)
if l == 0:
	k = test * c // 2
	print(M // k // 2 + M // k % 2)


from fractions import gcd
import sys
(n, m) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [i // 2 for i in a]

def div2check(i):
	count = 0
	while i % 2 == 0:
		count += 1
		i //= 2
	return count
c = [div2check(i) for i in b]
if c.count(c[0]) != n:
	print(0)
	sys.exit()
lcm = b[0]
for i in b[1:]:
	lcm = lcm * i // gcd(lcm, i)
print((m // lcm + 1) // 2)


import numpy as np
from math import ceil
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
a = [x // 2 for x in a]
lcm = np.lcm.reduce(a)
ans = 0
for i in a:
	if lcm // i % 2 == 0:
		break
else:
	ans = ceil(m // lcm / 2)
print(ans)


import fractions
from functools import reduce
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
	a[i] = a[i] // 2

def lcm_base(x, y):
	return x * y // fractions.gcd(x, y)

def lcm_list(numbers):
	return reduce(lcm_base, numbers, 1)
f2 = lcm_list(a)
ans = 0
for i in range(n):
	if f2 // a[i] % 2 != 1:
		print(ans)
		break
else:
	ans = m // f2
	print((ans + 1) // 2)


from math import gcd, ceil
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
a = [i // 2 for i in a]
l = 1
for i in a:
	l *= i // gcd(l, i)
for i in a:
	if l // i % 2 == 0:
		print(0)
		return
print(ceil(m // l / 2))


from fractions import gcd
from functools import reduce
(N, M) = map(int, input().split())
A = list(set(map(lambda x: int(x) // 2, input().split())))
lcm = A[0]
for a in A[1:]:
	l = lcm * a // gcd(lcm, a)
	if not (l // lcm % 2 and l // a % 2):
		print(0)
		exit()
	lcm = l
print((M // lcm + 1) // 2)


import sys
inputs = sys.stdin.readlines()
from fractions import gcd
from operator import mul
from functools import reduce
lcm = lambda x, y: x * y // gcd(x, y)
(n, m) = map(int, inputs[0].split())
A = list(map(int, inputs[1].split()))
g = reduce(gcd, A)
if all((a // g % 2 for a in A)):
	print(round((m + 1) / reduce(lcm, A)))
else:
	print(0)


from math import gcd
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
a = list(set(a))
a = list(map(lambda x: x // 2, a))

def lcm(q):
	x = q[0]
	for i in range(1, len(q)):
		x = x * q[i] // gcd(x, q[i])
	return x
lcma = lcm(a)
for i in range(len(a)):
	if lcma // a[i] % 2 == 0:
		print(0)
		exit()
temp = m // lcma
print(-(-temp // 2))


from fractions import gcd

def solve(n, m, aaa):
	lcm = 1
	for a in aaa:
		a //= 2
		lcm *= a // gcd(lcm, a)
		if lcm > m:
			return 0
	for a in aaa:
		if int(lcm / a) == lcm / a:
			return 0
	return (m // lcm + 1) // 2
(n, m) = list(map(int, input().split()))
aaa = list(map(int, input().split()))
print(solve(n, m, aaa))


(N, M) = map(int, input().split())
A = list(set(map(int, input().split())))

def gcd(m, n):
	if n == 0:
		return m
	return gcd(n, m % n)
LCM = A[0]
for a in A:
	LCM = LCM * a // gcd(LCM, a)
K = max(A)
for X in range(K // 2, M + 1, K):
	for a in A:
		if (X - a // 2) % a != 0:
			break
	else:
		print((M - X) // LCM + 1)
		exit()
print(0)


import fractions
(n, m) = map(int, input().split())
a = list(map(int, input().split()))

def gcd(x, y):
	if y == 0:
		return x
	else:
		return gcd(y, x % y)

def lcm(x, y):
	return x * y // gcd(x, y)
now = a[0]
for i in range(1, n):
	now = lcm(now, a[i])
	if now > 2 * m:
		print(0)
		exit(0)
for i in range(n):
	if now // a[i] % 2 == 0:
		print(0)
		exit(0)
print((m // (now // 2) + 1) // 2)


from functools import reduce
import math

def lcm_base(x, y):
	return x * y // math.gcd(x, y)

def lcm(*numbers):
	return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
	return reduce(lcm_base, numbers, 1)
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
a = [i // 2 for i in list(set(a))]
nothing = False
cnt_common = -1
for i in a:
	cnt = 0
	while i % 2 == 0:
		i = i // 2
		cnt += 1
	if cnt_common == -1:
		cnt_common = cnt
		continue
	if cnt_common != cnt:
		nothing = True
		break
b = lcm_list(a)
if nothing:
	print(0)
else:
	ans = (m - b) // (2 * b) + 1
	print(max(ans, 0))


(n, m) = map(int, input().split())
a = map(int, input().split())
from fractions import gcd

def lcm(a, b):
	return a * b // gcd(a, b)
l = 1
max2 = 0
min2 = 1000
for i in a:
	factor = (i ^ i - 1).bit_length()
	max2 = max(max2, factor)
	min2 = min(min2, factor)
	l = l * i // 2 // gcd(l, i // 2)
	if l > m:
		break
if l > m or min2 != max2:
	print(0)
else:
	ans = 1 if l <= m else 0
	m -= l
	print(ans + max(0, m // (2 * l)))


from fractions import gcd
from functools import reduce
(N, M, *A) = map(int, open(0).read().split())
Y = reduce(lambda a, b: a * b // gcd(a, b), A)
if any((Y // a % 2 == 0 for a in A)):
	print(0)
	quit()
print(M // (Y // 2) - M // Y)


import sys
read = sys.stdin.buffer.read
from fractions import gcd
from functools import reduce
(n, m, *alst) = list(map(int, read().split()))
mm = 2 * m

def lcm(x, y):
	g = gcd(x, y)
	if x // g % 2 == 0 or y // g % 2 == 0:
		print(0)
		quit()
	g = x * y // g
	if g > mm:
		print(0)
		quit()
	return g
g = reduce(lcm, alst)
res = mm // g
print(res // 2 + res % 2)


(N, M) = map(int, input().split())
a = list(map(int, input().split()))
for k in range(N):
	a[k] //= 2
foo = 1
while a[0] % 2 == 0:
	foo *= 2
	a[0] //= 2
for k in range(1, N):
	if a[k] % foo == 0 and a[k] % (2 * foo) != 0:
		a[k] //= foo
		continue
	else:
		print(0)
		return
ans = 0
import math
lcm = a.pop()
for k in range(1, N):
	b = a.pop()
	lcm = lcm * b // math.gcd(lcm, b)
	if lcm * foo > M:
		print(0)
		return
lcm *= foo
ans = int((M / lcm - 1) // 2 + 1)
print(ans)


from fractions import gcd

def lcm(p, q):
	return p * q // gcd(p, q)
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
x = 1
for i in range(n):
	a[i] = a[i] // 2
	x = lcm(x, a[i])
for i in range(n):
	if x // a[i] % 2 == 0:
		print(0)
		exit()
p = m // x
print(p // 2 if p % 2 == 0 else p // 2 + 1)


import math
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
LCM = A[0]
for i in range(1, N):
	LCM = LCM * A[i] // math.gcd(LCM, A[i])
for i in range(N):
	temp = LCM // A[i]
	if temp % 2 == 0:
		print(0)
		exit()
MIN = LCM // 2
nokori = M - MIN
ans = nokori // LCM + 1
print(ans)


from math import gcd
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
d = 1
a = A[0]
while a % 2 == 0:
	d *= 2
	a //= 2
if not all((a // d % 2 != 0 and a % d == 0 for a in A)):
	print(0)
	exit()
A = [a // d for a in A]
g = 1
for a in A:
	g = g * a // gcd(g, a)
g *= d // 2
x = M // g
print((x + 1) // 2)


from fractions import gcd
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
gcd_n = A[0]
for a in A:
	gcd_n = gcd(gcd_n, a)
for a in A:
	if a // gcd_n % 2 == 0:
		print(0)
		exit()
lcm_n = 1
for a in A:
	lcm_n = lcm_n * a // 2 // gcd(lcm_n, a // 2)
print((M // lcm_n + 1) // 2)


def solve():
	import math
	(N, M) = [int(i) for i in input().split()]
	A = list(map(int, input().split()))
	lcm = A[0]
	for i in range(1, N):
		lcm = lcm * A[i] // math.gcd(lcm, A[i])
	first = lcm // 2
	ans_exists = True
	for i in range(N):
		if first % A[i] == 0:
			ans_exists = False
	if ans_exists:
		ans = int((M - first) // lcm + 1)
		print(ans)
	else:
		print('0')

def __starting_point():
	solve()
__starting_point()


from math import gcd
(N, M) = list(map(int, input().split()))
A = list(map(int, input().split()))
lcm = 1
for a in A:
	lcm = lcm * a // gcd(lcm, a)
	if lcm > M * 2:
		print(0)
		return
for a in A:
	if lcm // a % 2 == 0:
		print(0)
		return
ans = M // (lcm // 2) - M // lcm
print(ans)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
from fractions import gcd
for i in range(n):
	a[i] //= 2
from copy import copy
b = copy(a)
c = []
for i in range(n):
	cnt = 0
	while b[i] % 2 == 0:
		cnt += 1
		b[i] //= 2
	c.append(cnt)
for i in range(n - 1):
	if c[i] != c[i + 1]:
		print(0)
		exit()
a_gcd = a[0]
for i in range(1, n):
	a_gcd = a_gcd * a[i] // gcd(a_gcd, a[i])
print((m + a_gcd) // (a_gcd * 2))


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
g = l.copy()
while not any((x % 2 for x in g)):
	g = [x // 2 for x in g]
if not all((x % 2 for x in g)):
	print(0)
	exit(0)

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
lcm = lambda a, b: a * b // gcd(a, b)
tot = 1
for x in l:
	tot = lcm(tot, x // 2)
print((m // tot + 1) // 2)


from fractions import gcd
import sys
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
a = [i // 2 for i in a]
cnt = 1
min_a = min(a)
while min_a % 2 == 0:
	cnt *= 2
	min_a = min_a // 2
ans = 1
for i in a:
	if i // cnt % 2 == 0:
		print(0)
		sys.exit()
	ans = ans * i // gcd(ans, i)
print((m // ans + 1) // 2)


from fractions import gcd
(N, M) = list(map(int, input().split()))
A = list(map(lambda x: int(x), input().split()))
cnt = [0 for _ in range(N)]
for i in range(N):
	a = A[i]
	while a % 2 == 0:
		a = a // 2
		cnt[i] += 1
if max(cnt) > min(cnt):
	print(0)
	return
C = max(cnt)
A = list(map(lambda x: x // pow(2, C), A))

def gcd(a, b):
	if a < b:
		(a, b) = (b, a)
	while a % b > 0:
		(a, b) = (b, a % b)
	return b

def lcm(a, b):
	return a * b // gcd(a, b)
x = A[0]
for a in A[1:]:
	x = lcm(x, a)
x = x * pow(2, C - 1)
print((M // x + 1) // 2)


import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache

def input():
	return sys.stdin.readline().strip()

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(map(int, input().split()))

def TUPLE():
	return tuple(map(int, input().split()))

def ZIP(n):
	return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 6
mod = 998244353
(N, M) = MAP()
a = LIST()
A = sorted([x // 2 for x in a], reverse=True)
lcm = A[-1]
for x in A:
	lcm = lcm * x // gcd(lcm, x)
r = lcm // A[0]
n = M // A[0]
for x in A:
	if lcm // x % 2 == 0:
		print(0)
		return
if r % 2 == 0:
	print(0)
else:
	print(n // r - n // (2 * r))


from fractions import gcd
(n, m) = map(int, input().split())
a = [i // 2 for i in set(list(map(int, input().split())))]
b = []
for i in a:
	c = i
	p = 0
	while c % 2 == 0:
		c //= 2
		p += 1
	b.append(p)
l = 1
if len(set(b)) == 1:
	for i in a:
		l = l * i // gcd(i, l)
		if m < l:
			print(0)
			break
	else:
		print((m // l + 1) // 2)
else:
	print(0)


from fractions import *
(n, m, *a) = map(int, open(0).read().split())
s = 1
d = set()
for i in a:
	i //= 2
	s *= i // gcd(s, i)
	t = 0
	while i % 2 < 1:
		t += 1
		i //= 2
	d |= {t}
print((0 - -(m // s) // 2) * (len(d) < 2))


def a():
	(N, M) = map(int, input().split())
	B = list(map(lambda x: int(x) // 2, input().split()))

	def gcd(n, m):
		while n:
			(m, n) = [n, m % n]
		return m
	su = 1
	for b in B:
		su *= b // gcd(su, b)
		if su > M:
			return 0
	for _ in filter(lambda x: su // x % 2 == 0, B):
		return 0
	return M // su - M // (su * 2)
print(a())


(N, M) = map(int, input().split(' '))
a = list(set(map(int, input().split(' '))))
g = a.copy()
while not any((x % 2 for x in g)):
	g = [i // 2 for i in g]
if not all((x % 2 for x in g)):
	print(0)
	exit(0)

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def lcm(a, b):
	return a * b // gcd(a, b)
tot = 1
for x in a:
	tot = lcm(tot, x // 2)
print((M // tot + 1) // 2)


from fractions import gcd
(N, M) = map(int, input().split())
a = list(map(int, input().split()))
if len(set([i & -i for i in a])) != 1:
	print(0)
else:
	x = a[0] // 2
	for i in range(1, len(a)):
		x = x * (a[i] // 2 // gcd(x, a[i] // 2))
	print(M // x - M // (2 * x))


from math import gcd, ceil
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
A = [a // 2 for a in A]
B = 1
for a in A:
	B *= a // gcd(B, a)
for a in A:
	if B // a % 2 == 0:
		print(0)
		return
print(ceil(M // B / 2))


def gcd_e(x, y):
	if y == 0:
		return x
	else:
		return gcd_e(y, x % y)

def lcm(x, y):
	return x * y // gcd_e(x, y)
(n, m) = list(map(int, input().split()))
A = list(map(int, input().split()))
(a, b) = (A[0], 0)
for i in range(1, n):
	b = A[i]
	a = lcm(a, b)
for i in set(A):
	if a // i % 2 == 0:
		print('0')
		exit()
if a // 2 > m:
	print('0')
else:
	print((m - a // 2) // a + 1)


(N, M) = map(int, input().split())
A = list(map(int, input().split()))
B = set([a & -a for a in A])
if len(B) > 1:
	print(0)
	exit()

def gcd(n, m):
	if m == 0:
		return n
	return gcd(m, n % m)

def lcm(x, y):
	return x * y // gcd(x, y)
A = [a // 2 for a in A]
LCM = A[0]
for a in A:
	LCM = lcm(LCM, a)
ans = (M // LCM + 1) // 2
print(ans)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))

def gcd(x, y):
	return x if y == 0 else gcd(y, x % y)

def lcm(x, y):
	return x * y // gcd(x, y)
k = 1
for i in l:
	i //= 2
	k = lcm(k, i)
	if k // i % 2 == 0 or k > m:
		print(0)
		break
else:
	print(m // k - m // (k * 2))


from fractions import gcd
from functools import reduce

def lcm_base(x, y):
	return x * y // gcd(x, y)

def lcm(A):
	return reduce(lcm_base, A, 1)
(n, m) = map(int, input().split())
A = list(map(int, input().split()))
num = lcm(A)
semi = num // 2
ans = 0
if any([True for i in range(n) if semi % A[i] == 0]):
	print(0)
elif semi <= m:
	ans += 1
	m -= semi
	ans += m // num
	print(ans)
else:
	print(0)


from fractions import gcd

def lcm(a, b):
	return a * b // gcd(a, b)
(N, M) = map(int, input().split())
B = set(map(lambda x: int(x) // 2, input().split()))
power = 1
for b in B:
	power = lcm(power, b)
mn = min(B)
p2 = power // mn
if p2 % 2 == 0:
	print(0)
	exit()
ans1 = M // mn // p2
ans2 = M // mn // (p2 * 2)
print(ans1 - ans2)


from fractions import gcd
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = [a[i] // 2 for i in range(n)]
lcm_a = 1
for i in range(n):
	lcm_a = lcm_a * b[i] // gcd(lcm_a, b[i])
for i in range(n):
	if lcm_a // b[i] % 2 == 0:
		print(0)
		exit()
if m < lcm_a:
	print(0)
else:
	m -= lcm_a
	print(1 + m // (lcm_a * 2))


def gcd(a, b):
	while a != 0:
		b = b % a
		(a, b) = (b, a)
	return b

def lcm(a, b):
	return a * b // gcd(a, b)
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
x = 1
for y in a:
	x = lcm(x, y // 2)
for y in a:
	if x // (y // 2) % 2 == 0:
		print(0)
		exit()
max_n = (m - x) // (2 * x)
print(max_n + 1)


import sys
import fractions
from functools import reduce
input = sys.stdin.readline
(n, m) = [int(x) for x in input().strip().split()]
a = [int(x) // 2 for x in input().strip().split()]
a = list(set(a))

def lcm_base(x, y):
	return x * y // fractions.gcd(x, y)
lcm = reduce(lcm_base, a, 1)
for x in a:
	if lcm // x % 2 == 0:
		print(0)
		break
else:
	print((m // lcm + 1) // 2)


def gcd(x, y):
	if x == 0:
		return y
	return gcd(y % x, x)
lcm = lambda x, y: x * y // gcd(x, y)
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
arr = [e // 2 for e in arr]
cm = arr[0]
for e in arr[1:]:
	cm = lcm(cm, e)
if any([cm // e % 2 == 0 for e in arr]):
	print(0)
	exit()
print((m // cm + 1) // 2)


(N, M) = map(int, input().split())
a = list(map(int, input().split()))
for k in range(N):
	a[k] //= 2
foo = 1
while a[0] % 2 == 0:
	foo *= 2
	a[0] //= 2
for k in range(1, N):
	if a[k] % foo == 0 and a[k] % (2 * foo) != 0:
		a[k] //= foo
		continue
	else:
		print(0)
		return
ans = 0
for odd in [3, 5, 7, 11]:
	flag = False
	for k in range(N):
		if a[k] % odd == 0:
			a[k] //= odd
			flag = True
	if flag:
		foo *= odd
import math
lcm = a.pop()
for k in range(1, N):
	b = a.pop()
	lcm = lcm * b // math.gcd(lcm, b)
	if lcm * foo > M:
		print(0)
		return
lcm *= foo
ans = int((M / lcm - 1) // 2 + 1)
print(ans)


from fractions import gcd
(n, m) = map(int, input().split())
A = list(map(int, input().split()))
l = 1
cnt = -1
for a in A:
	l = l * a // gcd(l, a)
	i = 0
	while a % 2 == 0:
		a = a // 2
		i += 1
	if cnt == -1:
		cnt = i
	elif cnt != i:
		print(0)
		exit(0)
ans = 1 + (m - l // 2) // l
print(ans)


from fractions import gcd
(n, m) = map(int, input().split())
a = [i // 2 for i in map(int, input().split())]
z = []
for i in a:
	n = 0
	while i % 2 == 0:
		i //= 2
		n += 1
	z.append(n)
if all((z[0] == i for i in z)):
	x = 1
	for i in a:
		x = x * i // gcd(x, i)
	result = -(-(m // x) // 2)
	print(result)
else:
	print(0)


(N, M) = map(int, input().split())
a = list(map(int, input().split()))
import fractions
from functools import reduce

def lcm_base(x, y):
	return x * y // fractions.gcd(x, y)

def lcm_list(numbers):
	return reduce(lcm_base, numbers, 1)
l = lcm_list(a)
for (s, t) in enumerate(a):
	if l // t % 2 == 0:
		print('0')
		exit()
print((2 * M // l + 1) // 2)


from fractions import gcd

def lcm(a, b):
	return a * b // gcd(a, b)
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
h = list(map(lambda x: x // 2, a))
l = 1
for i in range(n):
	l = lcm(l, h[i])
for i in range(n):
	if l // h[i] % 2 == 0:
		print(0)
		exit()
print((m // l + 1) // 2)


(N, M) = map(int, input().split())
a = list(map(int, input().split()))
from math import floor
from fractions import gcd
from functools import reduce

def lcm(x, y):
	return x * y // gcd(x, y)
b = [n // 2 for n in a]
lcm_b = reduce(lcm, b)
for n in b:
	if lcm_b // n % 2 == 0:
		print(0)
		exit()
n = floor((M / lcm_b - 1) / 2) + 1
print(n)


import fractions
import functools

def lcm(n1, n2):
	return n1 * n2 // fractions.gcd(n1, n2)
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
	A[i] //= 2
lcmA = functools.reduce(lcm, A)
gcdA = functools.reduce(fractions.gcd, A)
if lcmA // gcdA % 2 == 0:
	print(0)
else:
	print((M // lcmA + 1) // 2)


from math import gcd, ceil
from functools import reduce
import sys

def lcm_base(x, y):
	return x * y // gcd(x, y)

def lcm_list(numbers):
	return reduce(lcm_base, numbers, 1)
(N, M) = map(int, input().split())
a = [int(i) // 2 for i in input().split()]
s = set()
for x in a:
	cur = 0
	y = x
	while y % 2 == 0:
		cur += 1
		y //= 2
	s.add(cur)
	if len(s) >= 2:
		print(0)
		return
lcm = lcm_list(a)
print((M // lcm + 1) // 2)


import sys
import fractions
(N, M) = map(int, input().split())
A = [int(a) for a in input().split()]
A2 = [a >> 1 for a in A]
lcm = A2[0]
for i in range(1, N):
	lcm = lcm * A2[i] // fractions.gcd(lcm, A2[i])
	if lcm > M:
		print(0)
		sys.exit()
B = sum([1 for a in A if lcm % a == 0])
if B > 0:
	print(0)
else:
	print((M // lcm + 1) // 2)


import sys
import math
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.141592653589793

def read_str():
	return sys.stdin.readline().strip()

def read_int():
	return int(sys.stdin.readline().strip())

def read_ints():
	return map(int, sys.stdin.readline().strip().split())

def read_ints2(x):
	return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())

def read_str_list():
	return list(sys.stdin.readline().strip().split())

def read_int_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def GCD(a: int, b: int) -> int:
	return b if a % b == 0 else GCD(b, a % b)

def LCM(a: int, b: int) -> int:
	return a * b // GCD(a, b)

def Main():
	(n, m) = read_ints()
	a = read_int_list()
	a = [x // 2 for x in a]
	lcm = 1
	for x in a:
		lcm *= x // math.gcd(lcm, x)
	for x in a:
		if lcm // x % 2 == 0:
			print(0)
			return
	print(math.ceil(m // lcm / 2))

def __starting_point():
	Main()
__starting_point()


from fractions import gcd
import sys
input = sys.stdin.readline
(N, M) = map(int, input().split())
List = list(map(lambda x: int(x) // 2, map(int, set(input().split()))))

def main():
	LCM = 1
	for i in List:
		LCM *= i // gcd(LCM, i)
	for i in List:
		if LCM // i % 2 == 0:
			print(0)
			exit()
	print(int(M // (LCM * 2) + M % (LCM * 2) // LCM))
main()


from fractions import gcd
from math import ceil

def f(x):
	cnt = 0
	while x % 2 == 0:
		x //= 2
		cnt += 1
	return cnt
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = [a[i] // 2 for i in range(n)]
g = b[0]
for i in range(1, n):
	g = g * b[i] // gcd(g, b[i])
t = f(a[0])
for i in range(n):
	if t != f(a[i]):
		print(0)
		exit()
else:
	print(int((m / g + 1) // 2))


import sys
from math import gcd
from copy import deepcopy
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7

def lcm(a, b):
	return a * b // gcd(a, b)

def resolve():
	(n, m) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	A_ = deepcopy(A)
	cnt = [0] * n
	for i in range(n):
		while A_[i] % 2 == 0:
			A_[i] //= 2
			cnt[i] += 1
		if i != 0 and cnt[i] != cnt[i - 1]:
			print(0)
			return
	L = 1
	for a in A:
		L = lcm(L, a // 2)
	res = m // L - m // (L * 2)
	print(res)

def __starting_point():
	resolve()
__starting_point()


from fractions import gcd
(n, m) = map(int, input().split())
a = [int(i) // 2 for i in input().split()]

def lcm(x, y):
	return x * y // gcd(x, y)
l = 1
for i in a:
	l = lcm(l, i)
for i in a:
	if l // i % 2 == 0:
		print(0)
		exit()
print((m // l + 1) // 2)


(N, M) = map(int, input().split())
A = list(set(map(lambda x: int(x) // 2, input().split())))

def _gcd(a, b):
	return a if b == 0 else _gcd(b, a % b)

def _lcm(a, b):
	return a * b // _gcd(a, b)
lcm = A[0]
for ai in A[1:]:
	lcm = _lcm(lcm, ai)
ret = (M // lcm + 1) // 2
for ai in A[1:]:
	if lcm // ai % 2 == 0:
		ret = 0
		break
print(ret)


import sys, queue, math, copy
from fractions import gcd
input = sys.stdin.readline
LI = lambda : [int(x) for x in input().split()]
LI_2 = lambda : [int(x) / 2 for x in input().split()]
(N, M) = LI()
A = LI_2()
lcm = 1
for a in A:
	c = gcd(lcm, a)
	if lcm // c % 2 == 0:
		print(0)
		exit(0)
	lcm *= a // c
print(math.ceil(M // lcm / 2))


from math import gcd
from functools import reduce
import sys
input = sys.stdin.readline

def lcm(a, b):
	return a * b // gcd(a, b)

def count_factor_2(num):
	count = 0
	while num % 2 == 0:
		num //= 2
		count += 1
	return count

def main():
	(n, m) = list(map(int, input().split()))
	A = list([x // 2 for x in set(map(int, input().split()))])
	check = len(set(map(count_factor_2, A)))
	if check != 1:
		print(0)
		return
	lcm_a = reduce(lcm, A)
	step = lcm_a * 2
	ans = (m + lcm_a) // step
	print(ans)

def __starting_point():
	main()
__starting_point()


import fractions
from functools import reduce

def lcm_base(x, y):
	return x * y // fractions.gcd(x, y)

def lcm(*numbers):
	return reduce(lcm_base, numbers, 1)
(N, M) = map(int, input().split())
A = [int(i) // 2 for i in input().split()]
q = lcm(*A)
for i in A:
	if q // i % 2 == 0:
		print(0)
		exit()
print((M // q + 1) // 2)


from math import gcd
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
B = [a // 2 for a in A]
LCM = 1
for i in range(N):
	LCM = LCM * B[i] // gcd(LCM, B[i])
for i in range(N):
	if LCM // B[i] % 2 == 0:
		print(0)
		exit()
print((M // LCM + 1) // 2)


import sys
from fractions import gcd
(N, M) = map(int, input().split())
an = list(map(lambda x: int(x) // 2, input().split()))
lcm = an[0]
for a in an[1:]:
	l = lcm * a // gcd(lcm, a)
	if not l // lcm % 2 == l // a % 2:
		print(0)
		sys.exit()
	lcm = l
print((M // lcm + 1) // 2)


f = lambda : map(int, input().split())
(n, m) = f()
l = list(f())
import fractions as f
k = 1
for i in l:
	i //= 2
	k = k * i // f.gcd(k, i)
	if k // i % 2 < 1 or k > m:
		print(0)
		break
else:
	print(m // k - m // (k * 2))


from fractions import gcd

def lcm(a, b):
	return a * b // gcd(a, b)
(N, M) = map(int, input().split())
A = [int(i) for i in input().split()]
a = 0
b = A[0]
while b % 2 == 0:
	a += 1
	b = b // 2
for i in range(1, N):
	if A[i] % 2 ** a != 0 or A[i] % 2 ** (a + 1) == 0:
		print(0)
		exit()
c = A[0]
for i in range(N - 1):
	c = lcm(c, A[i + 1])
print((M + c // 2) // c)


import math
from functools import reduce
(n, m) = map(int, input().split())
A = list(map(int, input().split()))
a0 = A[0]
cnt = 0
while a0 % 2 == 0:
	a0 //= 2
	cnt += 1
a = []
for aa in A:
	if cnt == 1:
		if aa % 4 == 0:
			print(0)
			return
	elif aa % 2 ** (cnt - 1) != 0 or aa % 2 ** cnt != 0 or aa % 2 ** (cnt + 1) == 0:
		print(0)
		return
	a.append(aa // 2)

def lcm_base(p, q):
	return p * q // math.gcd(p, q)

def lcm_list(numbers):
	return reduce(lcm_base, numbers, 1)
lcm = lcm_list(a)
print(m // lcm - m // (lcm * 2))


from fractions import gcd
(n, m) = map(int, input().split())
a = set(map(int, input().split()))
a = list(a)
nn = len(a)
g = a[0]
x = a[0]
for i in range(1, nn):
	t = gcd(x, a[i])
	x *= a[i]
	x //= t
fl = 1
ff = x // 2
for i in range(nn):
	if ff % a[i] != a[i] // 2:
		fl = 0
if fl == 1:
	xx = (m - ff) // x + 1
else:
	xx = 0
print(xx)


def gcd(a, b):
	if b == 0:
		return a
	r = a % b
	return gcd(b, r)

def lcm(a, b):
	x = gcd(a, b)
	return a * b // x

def gcdN(a):
	x = a[0]
	for i in range(1, len(a)):
		x = gcd(x, a[i])
	return x

def lcmN(a):
	x = a[0]
	for i in range(1, len(a)):
		x = lcm(x, a[i])
	return x
(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
g = gcdN(a)
for i in a:
	if i // g % 2 == 0:
		print(0)
		break
else:
	l = lcmN(a)
	k = 2 * m // l
	print((k + 1) // 2)


def abc150_d():
	(n, m) = (int(x) for x in input().split())
	A = [int(x) // 2 for x in input().split()]
	from math import gcd

	def lcm(a, b):
		return a * b // gcd(a, b)
	x = 1
	for a in A:
		x = lcm(x, a)
	valid = True
	for a in A:
		if x // a % 2 == 0:
			valid = False
			break
	if valid:
		ans = (m // x + 1) // 2
	else:
		ans = 0
	print(ans)

def __starting_point():
	abc150_d()
__starting_point()


import sys, fractions
input = sys.stdin.readline
(N, M) = map(int, input().split())
aa = list(map(int, input().split()))
lcm = 1
i = 1
for a in aa:
	lcm = a * lcm // fractions.gcd(a, lcm)
ans = 0
ch = True
for a in aa:
	if 0 != (lcm // 2 - a // 2) % a:
		ch = False
if ch:
	ans += M // lcm
	if M % lcm >= lcm // 2:
		ans += 1
	print(ans)
else:
	print(0)


from fractions import gcd
from math import ceil

def lcm(a, b):
	return a * b // gcd(a, b)
(n, M) = map(int, input().split())
A = tuple(map(lambda x: int(int(x) / 2), input().split()))
scm_core = 1
for a in A:
	scm_core = lcm(scm_core, a)
canmake_scm = True
for a in A:
	if scm_core // a % 2 == 0:
		canmake_scm = False
if canmake_scm:
	print(ceil(M // scm_core / 2))
else:
	print(0)


from functools import reduce
import fractions
(n, m) = map(int, input().split())
a = [int(x) // 2 for x in input().split()]
y = a[0]
for i in range(1, n):
	y = y * a[i] // fractions.gcd(y, a[i])
	if y > m:
		print(0)
		exit()
for i in range(n):
	if y // a[i] % 2 == 0:
		print(0)
		exit()
x = m // y
if x % 2 == 0:
	print(x // 2)
else:
	print((x + 1) // 2)


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
if n == 1:
	l = arr[0]
else:
	l = lcm(arr[0], arr[1])
for i in range(2, n):
	l = lcm(l, arr[i])
	if l // 2 > m:
		print(0)
		exit()
for i in range(n):
	if l // arr[i] % 2 == 0:
		print(0)
		exit()
ans = (m - l // 2) // l + 1
print(ans)


from math import gcd

def lcm(a, b):
	return a // gcd(a, b) * b

def lcm(ab):
	l = len(ab)
	ret = ab[0]
	for i in range(1, l):
		ret = ret // gcd(ab[i], ret) * ab[i]
	return ret

def count2(a):
	ret = 0
	while a % 2 == 0:
		a //= 2
		ret += 1
	return 2 ** ret
(n, m) = map(int, input().split())
A = list(map(int, input().split()))
if any((i % 2 for i in A)):
	print(0)
	return
A = [i // 2 for i in A]
p = lcm(A)
c = count2(p)
if any((i % c for i in A)):
	print(0)
	return
x = m // p
print(-(-x // 2))


from fractions import gcd

def lcm(nums):
	ret = 1
	for i in nums:
		ret = ret * i // gcd(ret, i)
		if ret > m:
			return m + 1
	return ret
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = [i // 2 for i in a]
g = lcm(b)
if any((g // i % 2 == 0 for i in b)):
	ans = 0
else:
	ans = (m // g + 1) // 2
print(ans)


from fractions import gcd

def lcm(p, q):
	return p * q // int(gcd(p, q))
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
B = []
for i in range(N):
	b = 0
	while A[i] % 2 == 0:
		A[i] >>= 1
		b += 1
	B.append(b)
S = set(B)
if len(S) != 1:
	print(0)
else:
	P = 1
	for i in range(N):
		P = lcm(P, A[i])
	print((M // 2 ** (list(S)[0] - 1) + P) // (2 * P))


import fractions
(N, M) = map(int, input().split())
l_a = list(map(int, input().split()))
l_num = []
lcm = 1
flg = True
for a in l_a:
	a //= 2
	if not a in l_num:
		l_num.append(a)
	lcm = lcm * a // fractions.gcd(lcm, a)
	if lcm > M:
		flg = False
		break
if flg:
	for num in l_num:
		if lcm > num and lcm // num % 2 == 0:
			flg = False
if flg:
	print((M // lcm + 1) // 2)
else:
	print(0)


from math import gcd

def lcm(a, b):
	return a // gcd(a, b) * b
(N, M) = map(int, input().split())
As = list(map(int, input().split()))
rightmostbit = As[0] & -As[0]
for A in As[1:]:
	if rightmostbit != A & -A:
		print(0)
		return
lcm_of_half_As = 1
for A in As:
	lcm_of_half_As = lcm(lcm_of_half_As, A // 2)
	if lcm_of_half_As > M:
		break
print((M // lcm_of_half_As + 1) // 2)


from fractions import gcd
(n, m, *a) = map(int, open(0).read().split())
lcm = a[0] // 2
for x in a:
	x //= 2
	g = gcd(lcm, x)
	if lcm // g % 2 != x // g % 2:
		print(0)
		exit()
	lcm = lcm * x // g
print((m // lcm + 1) // 2)


from math import gcd
(n, m) = list(map(int, input().split()))
A = list(map(int, input().split()))
A = [a // 2 for a in A]
lcm = 1
for i in range(n):
	lcm = lcm * A[i] // gcd(lcm, A[i])
	if lcm > m:
		print(0)
		return
for a in A:
	if lcm // a % 2 == 0:
		print(0)
		return
print((m // lcm + 1) // 2)


def main():
	import math
	(n, m) = list(map(int, input().split()))
	a = sorted(list(map(int, input().split())))
	for i in range(n):
		a[i] //= 2
	g = 1
	for i in range(n):
		g = a[i] * g // math.gcd(g, a[i])
	for i in range(n):
		if g // a[i] % 2 == 0:
			print(0)
			return
	if g > m:
		print(0)
		return
	print(1 + (m - g) // (2 * g))

def __starting_point():
	main()
__starting_point()


from math import gcd
(N, M) = list(map(int, input().split()))
A = list(map(int, input().split()))
A = [i // 2 for i in A]
lcd = 1
for a in A:
	lcd *= a // gcd(lcd, a)
for a in A:
	if lcd // a % 2 == 0:
		print(0)
		return
print((M // lcd + 1) // 2)


from fractions import gcd
(n, m) = map(int, input().split())
a = [int(i) // 2 for i in input().split()]
x = 1
for i in range(n):
	x *= a[i] // gcd(x, a[i])
for i in a:
	if x // i % 2 == 0:
		print(0)
		exit()
print((m // x + 1) // 2)


def gcd(a, b):
	(a, b) = (min(a, b), max(a, b))
	if a != 0:
		return gcd(b % a, a)
	else:
		return b
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=1)
g = a[0]
c = a[0]
mi = a[0] // 2
for i in a[1:]:
	while mi <= m:
		if (mi - i // 2) % i == 0:
			break
		else:
			mi += c
	if mi > m:
		print(0)
		exit()
	g = gcd(i, c)
	c *= i
	c = c // g
print((m - mi) // c + 1)


import sys
import fractions as f
(n, m) = map(int, input().split())
A = list(map(int, input().split()))
a = A[0]
b = 0
while a % 2 == 0:
	a = a // 2
	b = b + 1
b = 2 ** b
B = [0] * n
for i in range(n):
	B[i] = A[i] // b
	if B[i] * b != A[i] or B[i] % 2 == 0:
		print(0)
		sys.exit()
G = 1
for i in range(n):
	G = G * B[i] // f.gcd(G, B[i])
print(int(m + G * b // 2) // (G * b))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))

def f(a_k):
	count = 0
	while a_k % 2 == 0:
		count += 1
		a_k = a_k // 2
	return count
b = []
f_0 = f(a[0])
for a_k in a:
	f_k = f(a_k)
	if f_k != f_0:
		print(0)
		return
	b.append(a_k // pow(2, f_k))
import math

def lcm(x, y):
	return x * y // math.gcd(x, y)
b_lcm = 1
for b_k in b:
	b_lcm = lcm(b_lcm, b_k)
a_lcm = b_lcm * pow(2, f_0)
print((m + a_lcm // 2) // a_lcm)


(n, m) = map(int, input().split())
aas = set(list(map(int, input().split())))
a = [i // 2 for i in aas]
import math
N = len(a)

def n_of_twos(x):
	res = 0
	while x % 2 ** (res + 1) == 0:
		res += 1
	return res
if N >= 2:
	n_of_twos_0 = n_of_twos(a[0])
	for i in range(1, N):
		if n_of_twos(a[i]) != n_of_twos_0:
			print(0)
			return
ans = a[0]
for i in range(1, N):
	ans = ans * a[i] // math.gcd(ans, a[i])
if ans > m:
	print(0)
	return
print(1 + (m // ans - 1) // 2)


import sys
from fractions import gcd
inputs = sys.stdin.readlines()
(n, m) = map(int, inputs[0].split())
A = list(set(map(int, inputs[1].split())))
a = A[0]
for i in range(1, len(A)):
	z = gcd(a, A[i])
	(x, y) = (a // z, A[i] // z)
	if x % 2 == y % 2 == 1:
		a = x * y * z
	else:
		print(0)
		break
else:
	print(round((m + 1) / a))


from math import gcd

def lcm(a, b):
	return a * b // gcd(a, b)
(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
l = [0] * n
for i in range(n):
	tmp = a[i]
	while tmp % 2 == 0:
		tmp //= 2
		l[i] += 1
	if i > 0 and l[i] != l[i - 1]:
		print(0)
		return
res = 1
for i in range(n):
	res = lcm(res, a[i] // 2)
print(m // res - m // (res * 2))


import math

def lcm(a, b):
	return a * b // math.gcd(a, b)

def f(num):
	cnt = 0
	while num % 2 == 0:
		num = num // 2
		cnt += 1
	return cnt
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
	a[i] = a[i] // 2
t = f(a[0])
for i in range(n):
	if f(a[i]) != t:
		print(0)
		return
	a[i] = a[i] >> t
m = m >> t
l = 1
for i in range(n):
	l = lcm(l, a[i])
	if l > m:
		print(0)
		return
m = m // l
print((m + 1) // 2)


from fractions import gcd

def lcm(a, b):
	return a * b // gcd(a, b)
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
B = set()
l = 1
for i in range(len(A)):
	c = 0
	a = A[i]
	while a % 2 == 0:
		a //= 2
		c += 1
	if i == 0:
		c0 = c
	elif c0 != c:
		print(0)
		exit()
	l = lcm(l, A[i] // 2)
print((M + l) // (2 * l))


from fractions import gcd
from functools import reduce

def l(a, b):
	return a * b // gcd(a, b)

def L(N):
	return reduce(l, N)
(n, m) = map(int, input().split())
A = list(map(lambda x: int(x) // 2, input().split()))
a = A[0]
c = 0
while a % 2 == 0:
	a //= 2
	c += 1
if any([(a % 2 ** c == 0 and a // 2 ** c) % 2 == 0 for a in A]):
	print(0)
	exit()
a = L(A)
print((m + a) // (2 * a))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def lcm(a, b):
	return a * b // gcd(a, b)
l = a[0] // 2
ll = a[0]
for i in range(1, n):
	if a[i] % 2:
		odd = True
	else:
		even = True
	l = lcm(l, a[i] // 2)
	ll = lcm(ll, a[i])
	if l > m:
		print(0)
		exit()
for i in range(n):
	if l % a[i] == 0:
		print(0)
		exit()
print((m - l) // ll + 1)


(N, M) = map(int, input().split())
A = list(map(int, input().split()))
import sys
from math import gcd

def lcm(a, b):
	return a // gcd(a, b) * b
ans = 0
L = 1
for i in range(N):
	L = lcm(L, A[i])
	if L > 2 * M:
		print(0)
		sys.exit()
L2 = L
L1 = L // 2
for a in A:
	if L // a & 1 == 0:
		print(0)
		sys.exit()
ans = M // L1 - M // L2
print(ans)


def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def div_ceil(x, y):
	return (x + y - 1) // y
(N, M) = map(int, input().split())
(*A,) = map(int, input().split())
A = list(set([a // 2 for a in A]))
L = A[0]
for a in A[1:]:
	L *= a // gcd(L, a)
for a in A:
	if L // a % 2 == 0:
		ans = 0
		break
else:
	ans = div_ceil(M // L, 2)
print(ans)


import math
from decimal import Decimal, ROUND_HALF_UP

def lcm(a):
	x = a[0]
	for i in range(1, len(a)):
		x = x * a[i] // math.gcd(x, a[i])
	return x

def gcd(a):
	temp = math.gcd(a[0], a[1])
	for i in a:
		temp = math.gcd(temp, i)
	return temp
(n, m) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
zero = False
count = 0
mini = lcm(a)
if len(a) != 1:
	maxi = gcd(a)
else:
	maxi = a[0]
maxi2 = maxi
nibai = 1
while True:
	if maxi2 % 2 == 0:
		nibai *= 2
		maxi2 //= 2
	else:
		break
for i in a:
	if i % (2 * nibai) == 0:
		zero = True
		break
if not zero:
	t = Decimal(str(m * 2 // mini / 2))
	print(t.quantize(Decimal('0'), rounding=ROUND_HALF_UP))
else:
	print(0)


from math import gcd

def lcm(x, y):
	return x * y // gcd(x, y)

def cnt(x):
	i = 0
	while x % 2 == 0:
		x = x // 2
		i += 1
	return i
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
memo = cnt(a[0])
for i in range(n):
	if cnt(a[i]) != memo:
		print(0)
		return
	a[i] = a[i] // 2
t = 1
for i in range(n):
	t = lcm(t, a[i])
print(m // t - m // (2 * t))


import fractions
(n, m) = map(int, input().split())
A = list(map(lambda x: int(x) // 2, input().split()))
lcm = A[0]
for i in range(1, n):
	lcm = lcm * A[i] // fractions.gcd(lcm, A[i])
	if lcm > m:
		print(0)
		exit()
if any([i for i in range(n) if lcm % (A[i] * 2) == 0]):
	print(0)
	exit()
ans = m // (2 * lcm)
print(ans if m // lcm % 2 == 0 else ans + 1)


from math import gcd
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
g = A[0]
check = g & -g
for a in A:
	if check != a & -a:
		check = -1
		break
	g = g * a // gcd(a, g)
if check >= 0:
	g //= 2
	print((M // g + 1) // 2)
else:
	print(0)


from fractions import gcd
lcm = lambda a, b: a * b // gcd(a, b)
(N, M, *A) = map(int, open(0).read().split())
Y = A[0]
for a in A[1:]:
	Y = lcm(Y, a)
	if Y > 2 * M:
		print(0)
		quit()
print(M // (Y // 2) - M // Y if all((Y // a % 2 for a in A)) else 0)


from fractions import gcd
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
lcm = 1

def f(n):
	res = 0
	while n % 2 == 0:
		res += 1
		n //= 2
	return res
t = f(A[0])
for a in A:
	if t != f(a):
		print(0)
		exit()
	a //= 2
	lcm *= a // gcd(lcm, a)
print(M // lcm - M // (lcm * 2))


from fractions import gcd
from functools import reduce
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
AA = list(map(lambda x: x // 2, A))

def lcm(x, y):
	return x * y // gcd(x, y)
b0 = AA[0] & -AA[0]
for a in AA[1:]:
	if b0 != a & -a:
		print(0)
		break
else:
	a = reduce(lcm, AA)
	print(M // a - M // (2 * a))


(N, M) = map(int, input().split())
A = list(map(int, input().split()))
from fractions import gcd
from functools import reduce
x = reduce(lambda x, y: x * y // gcd(x, y), A)
print(0 if any([x // a % 2 == 0 for a in A]) else (M + x // 2) // x)


import sys

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
(n, m) = map(int, input().split())
a = tuple(map(int, input().split()))
lcm = 1
for i in a:
	lcm = lcm * i // gcd(lcm, i)
for i in a:
	if lcm // i % 2 == 0:
		print(0)
		sys.exit()
print((m + lcm // 2) // lcm)


from fractions import gcd

def f(a):
	res = 0
	while a % 2 == 0:
		a //= 2
		res += 1
	return res
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
t = f(a[0])
for i in range(n):
	if t != f(a[i]):
		print(0)
		exit()
l = 1
for i in range(n):
	b = a[i] // 2
	l = b * l // gcd(l, b)
print(int((m / l + 1) // 2))


import fractions
import math

def lcm(x, y):
	return x * y // fractions.gcd(x, y)
(n, m) = list(map(int, input().split()))
a = list(map(lambda x: int(x) // 2, input().split()))
lcm_all = 1
for e in a:
	lcm_all = lcm(lcm_all, e)
	if lcm_all // e % 2 == 0:
		print(0)
		exit()
print(math.ceil(m // lcm_all / 2))


def GCD(x, y):
	if y == 0:
		return x
	return GCD(y, x % y)

def LCM(x, y):
	return x * y // GCD(x, y)
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
ans = 1
for i in A:
	i //= 2
	ans = LCM(ans, i)
	if ans // i % 2 == 0:
		print(0)
		exit()
	if ans > M:
		print(0)
		exit()
print(M // ans - M // (ans * 2))


import sys
input = sys.stdin.readline
import math
(N, M) = (int(x) for x in input().rstrip('\n').split())
As = [int(x) for x in input().rstrip('\n').split()]
n = 1
use2 = 0
check = 0
for i in range(N):
	x = As[i]
	if i == 0:
		while x % 2 == 0:
			use2 += 1
			x = x // 2
		lcm = x
	else:
		use = 0
		while x % 2 == 0:
			x = x // 2
			use += 1
		if use2 != use:
			check += 1
			break
		lcm = lcm * x // math.gcd(lcm, x)
if check > 0:
	print(0)
else:
	LCM = 2 ** (use2 - 1)
	LCM = LCM * lcm
	print((M // LCM + 1) // 2)


import fractions
import sys
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
lcm = a[0]
for i in range(1, len(a)):
	lcm = lcm * a[i] // fractions.gcd(lcm, a[i])
for i in a:
	if lcm // i % 2 == 0:
		print(0)
		sys.exit()
lcm //= 2
print(m // lcm - m // (lcm * 2))


import math
from functools import reduce
(n, m) = input().split()
a = list(map(int, input().split()))
b = [0] * int(n)
for i in range(len(a)):
	b[i] = a[i] // 2

def lcm_base(x, y):
	return x * y // math.gcd(x, y)

def lcm_list(numbers):
	return reduce(lcm_base, numbers, 1)
c = 0
x = lcm_list(b)
for i in range(int(n)):
	if x // b[i] % 2 == 0:
		c = -1
		break
	else:
		continue
if c == -1:
	print(0)
else:
	print(math.floor((int(m) / x + 1) / 2))


import math
from functools import reduce

def lcm_base(x, y):
	return x * y // math.gcd(x, y)

def lcm(*numbers):
	return reduce(lcm_base, numbers, 1)

def div2_n(x):
	n = 0
	while x % 2 == 0:
		if x % 2 == 0:
			n += 1
			x >>= 1
	return n
(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
a2 = [i // 2 for i in a]
n0 = div2_n(a2[0])
for i in range(1, n):
	if div2_n(a2[i]) != n0:
		print(0)
		return
a2_l = lcm(*a2)
print(m // a2_l - m // (a2_l * 2))


import math
(N, M) = map(int, input().split())
nums = list(map(int, input().split()))
lcm = 1
b_cnt = -1
for num in nums:
	lcm = lcm * (num // 2) // math.gcd(lcm, num // 2)
	count = 0
	while num % 2 == 0:
		count += 1
		num //= 2
	if b_cnt < 0:
		b_cnt = count
	elif count != b_cnt:
		print(0)
		exit()
print((M + lcm) // (lcm * 2))


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(n):
	a[i] = a[i] // 2

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def check(x):
	cnt = 0
	while 1:
		if x % 2 == 0:
			x = x // 2
			cnt += 1
		else:
			break
	return cnt
cnt = a[0]
for i in range(n):
	cnt = lcm(cnt, a[i])
l = check(a[0])
for i in range(1, n):
	x = check(a[i])
	if x != l:
		print(0)
		return
s = m // cnt
if s % 2 == 0:
	print(s // 2)
else:
	print(s // 2 + 1)


import fractions as f
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
g = 1

def check(n):
	cnt = 0
	while n % 2 == 0:
		n //= 2
		cnt += 1
	return cnt
chk = check(a[0])
for i in a:
	if chk != check(i):
		print(0)
		exit()
	else:
		chk = check(i)
for i in range(n):
	g = g * (a[i] // 2) // f.gcd(g, a[i] // 2)
	if g > m:
		print(0)
		exit()
print(m // g - m // (2 * g))


import fractions
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
	a[i] = a[i] // 2

def count_2(k):
	c = 0
	while k % 2 == 0:
		k = k // 2
		c += 1
	return c
count = count_2(a[0])
for i in range(n):
	if count != count_2(a[i]):
		print(0)
		exit()
ans = a[0]
for i in range(1, n):
	ans = ans * a[i] // fractions.gcd(ans, a[i])
print((m // ans + 1) // 2)


from collections import deque, defaultdict

def gcd(a, b):
	return b if not a % b else gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)
(n, m) = list(map(int, input().split()))
A = [int(i) for i in input().split()]
tmp = A[0]
for i in range(1, n):
	tmp = lcm(tmp, A[i])
ans = m // tmp
lis = set()
for i in A:
	r = i
	k = 0
	while r % 2 == 0:
		k += 1
		r //= 2
	lis.add(k)
if m // tmp * tmp + tmp // 2 <= m:
	ans += 1
if len(lis) != 1:
	ans = 0
print(ans)


import math

def n_2(n):
	c = 0
	while n % 2 == 0:
		c += 1
		n >>= 1
	return (n, c)
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
(A[0], a) = n_2(A[0])
p = False
for i in range(1, N):
	(A[i], b) = n_2(A[i])
	if a != b:
		p = True
		break
if p:
	print(0)
	exit()
n = 1
for _ in range(a - 1):
	n *= 2
l = n
for a in A:
	l = l * a // math.gcd(l, a)
ans = M // l - M // (2 * l)
print(ans)


import fractions
import sys
input = sys.stdin.readline

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
g = a[0]
for i in range(1, n):
	g = g * a[i] // gcd(g, a[i])
for i in a:
	if g // 2 % i == 0:
		print(0)
		exit()
print(-(-(m * 2 // g) // 2))


import math
import fractions
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
num = 1
cnt = []
for x in a:
	c = 0
	for i in range(int(math.log(x, 2))):
		if x >> c & 1:
			break
		else:
			c += 1
	cnt.append(c)
if max(cnt) != min(cnt):
	print(0)
else:
	for x in a:
		num = num * (x // 2) // fractions.gcd(num, x // 2)
	print(m // num - m // num // 2)


import fractions
(n, m) = map(int, input().split())
l = input().split()
lcm = 1
sum = 0
for i in range(len(l)):
	lcm = int(l[i]) * lcm // fractions.gcd(int(l[i]), lcm)
for i in range(len(l)):
	if lcm // int(l[i]) % 2 == 1:
		sum += 1
if sum == len(l):
	x = m // (int(lcm) // 2)
	y = m // lcm
	print(int(x - y))
else:
	print(0)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))

def func(n):
	ret = 0
	n = n / 2
	while n.is_integer():
		ret += 1
		n = n / 2
	return ret
b = func(a[0])
for i in range(1, n):
	if b == func(a[i]):
		continue
	else:
		print(0)
		exit(0)
from fractions import gcd
lcmn = a[0] // 2
for i in range(1, n):
	lcmn = lcmn * a[i] // 2 // gcd(lcmn, a[i] // 2)
print((1 + m // lcmn) // 2)


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))

def gcd(num1, num2):
	r = 1
	while r > 0:
		r = num1 % num2
		num1 = num2
		num2 = r
	return num1

def lcm(num1, num2):
	gcd1 = gcd(num1, num2)
	return num1 * num2 // gcd1
lcm1 = a[0] // 2
lcm2 = a[0]
for i in range(1, n):
	t = a[i]
	lcm1 = lcm(lcm1, t // 2)
	lcm2 = lcm(lcm2, t)
	ta = max(t // 2, lcm1)
	tb = min(t // 2, lcm1)
	if ta != tb and ta // tb % 2 == 0:
		lcm1 = 0
		lcm2 = 0
		break
if lcm1 != 0:
	ans1 = m // lcm1
	ans2 = m // lcm2
	ans = ans1 - ans2
else:
	ans = 0
print(ans)


import fractions
(n, m) = map(int, input().split())
(*a,) = map(int, input().split())
lcm = a[0] // 2
for x in a:
	x //= 2
	g = fractions.gcd(lcm, x)
	if lcm // g % 2 != x // g % 2:
		print(0)
		quit()
	lcm = lcm * x // g
print((m // lcm + 1) // 2)


f = lambda : map(int, input().split())
(n, m) = f()
a = list(f())
from fractions import *
l = 1
for i in a:
	i //= 2
	l = l * i // gcd(l, i)
	if l // i % 2 < 1 or l > m:
		print(0)
		exit()
print(m // l - m // (l * 2))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
import math
lcm = 1
for i in range(n):
	b = a[i] // 2
	lcm = lcm * b // math.gcd(lcm, b)
if any((2 * lcm // i % 2 == 0 for i in a)):
	print(0)
else:
	print((m - lcm) // (2 * lcm) + 1)


from fractions import gcd
from functools import reduce

def lcm(x, y):
	g = gcd(x, y)
	x //= g
	y //= g
	if x & y & 1:
		l = x * y * g
		if l > 10 ** 9:
			return 0
		return l
	return 0
(n, m) = map(int, input().split())
A = list(map(lambda x: int(x) // 2, input().split()))
k = reduce(lcm, A)
if k == 0:
	print(0)
else:
	print((m // k + 1) // 2)


import math
import sys
from functools import reduce
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
	A[i] = A[i] // 2

def lcm_base(x, y):
	return x * y // math.gcd(x, y)

def lcm_list(numbers):
	return reduce(lcm_base, numbers, 1)
C = lcm_list(A)
B = [0 for _ in range(N)]
for i in range(N):
	B[i] = C // A[i]
	if B[i] % 2 == 0:
		print(0)
		return
print((M // C + 1) // 2)


import math
from functools import reduce
(n, m) = map(int, input().split())
A = list(map(int, input().split()))

def lcm_base(x, y):
	return x * y // math.gcd(x, y)

def lcm(target_list):
	return reduce(lcm_base, target_list)
A_gcd = reduce(math.gcd, A)
flg = True
for a in A:
	if a // A_gcd % 2 == 0:
		flg = False
		break
if flg:
	min_x = int(lcm(A)) // 2
	ans = m // min_x - m // (2 * min_x)
	print(ans)
else:
	print(0)


(n, m, *a) = map(int, open(0).read().split())
c = [bin(i)[::-1].index('1') for i in a]
if sum(c) != c[0] * n:
	print(0)
	exit()
import fractions

def lcm(x, y):
	return x * y // fractions.gcd(x, y)
a = list(set(a))
b = a[0]
for i in a:
	b = lcm(i, b)
	if b > 2 * m:
		print(0)
		exit()
print((m - b // 2) // b + 1)


from math import gcd
(N, M) = map(int, input().split())
A = [int(i) for i in input().split()]
flag = False
res = 1
for a in A:
	a //= 2
	res *= a // gcd(res, a)
	if res > M:
		flag = True
		break
for a in A:
	if int(res / a) == res / a:
		flag = True
if flag:
	ans = 0
	print(ans)
else:
	ans = (M // res + 1) // 2
	print(ans)


import math

def lcm(a, b):
	return a * b // math.gcd(a, b)

def co(num):
	return format(num, 'b')[::-1].find('1')
(N, M) = map(int, input().split())
L = list(map(int, input().split()))
L2 = [co(i) for i in L]
if len(set(L2)) != 1:
	print(0)
	return
L = [i // 2 for i in L]
s = L[0]
for i in range(N):
	s = lcm(s, L[i])
c = M // s
print((c + 1) // 2)


from functools import reduce
from fractions import gcd
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
a = [i // 2 for i in a]
lc = reduce(lambda x, y: x * y // gcd(x, y), a)
flag = True
for i in a:
	if lc // i % 2 == 0:
		flag = False
		break
if flag == False:
	print(0)
else:
	x = m // lc
	print(x // 2) if x % 2 == 0 else print(x // 2 + 1)


(N, M) = map(int, input().split())
A = list(map(int, input().split()))

def gcd(a, b):
	while b > 0:
		(a, b) = (b, a % b)
	return a
G = A[0] / 2
for a in A[1:]:
	G *= a / 2 / gcd(G, a // 2)
for a in A:
	if G % a == 0:
		print(0)
		exit()
print(int(M // G - M // G // 2))


from math import gcd
from functools import reduce
(n, m) = map(int, input().split())
lst = list(map(lambda x: int(x) // 2, input().split()))
divi = 0
x = lst[0]
while x % 2 == 0:
	x //= 2
	divi += 1
for i in range(1, n):
	divi2 = 0
	x = lst[i]
	while x % 2 == 0:
		x //= 2
		divi2 += 1
	if divi != divi2:
		print(0)
		exit()
work = reduce(lambda x, y: x * y // gcd(x, y), lst)
print((m // work + 1) // 2)


from fractions import gcd
(N, M) = map(int, input().split())
A = [int(i) // 2 for i in input().split()]
A_lcm = 1
for i in range(N):
	A_lcm *= A[i] // gcd(A_lcm, A[i])
for i in A:
	if A_lcm // i % 2 == 0:
		print(0)
		exit()
print((M // A_lcm + 1) // 2)


(N, M) = map(int, input().split())
A = list(map(int, input().split()))
from fractions import gcd

def Lcm(x):
	L = 1
	for a in x:
		a = a // 2
		L = a // gcd(a, L) * L
	return L
X = Lcm(A)
fg = 0
for i in A:
	if X // (i // 2) % 2 == 0:
		fg = 1
		break
if fg == 1:
	print(0)
else:
	print((M // X + 1) // 2)


from math import gcd
import sys
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
lcm = 1
for a in A:
	gcd_ = gcd(lcm, a // 2)
	lcm = lcm * (a // 2 // gcd_)
for a in A:
	if lcm // (a // 2) % 2 == 0:
		print(0)
		sys.exit()
print(M // lcm - M // (2 * lcm))


from math import gcd
(N, M) = map(int, input().split())
A = [a // 2 for a in map(int, input().split())]
lcm = 1
for a in A:
	lcm = lcm * a // gcd(lcm, a)
	if lcm > M:
		print(0)
		exit()
for a in A:
	div = lcm // a
	if div % 2 == 0:
		print(0)
		exit()
ans = (M // lcm + 1) // 2
print(ans)


import math
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = {}
for i in range(n):
	count = 0
	temp = a[i]
	while temp % 2 == 0:
		count += 1
		temp //= 2
	b.setdefault(count, 0)
	b[count] += 1
if len(b.keys()) >= 2:
	ans = 0
else:
	temp = 1
	for i in range(n):
		temp = temp * a[i] // math.gcd(temp, a[i])
	temp2 = temp // 2
	ans = m // temp2 - m // temp
print(ans)


from fractions import gcd
from functools import reduce
from math import ceil
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(lambda x: format(x, 'b')[::-1].find('1'), a))
if len(set(b)) != 1:
	print(0)
else:
	c = list(map(lambda x: x // 2, a))
	t = reduce(lambda x, y: x * y // gcd(x, y), c)
	print(ceil(m // t / 2))


from fractions import gcd
from functools import reduce
(N, M) = map(int, input().split())
a = list(map(int, input().split()))
a = [x // 2 for x in a]

def solve(p, q):
	g = gcd(p, q)
	p //= g
	q //= g
	if (p - q) % 2 == 1:
		return 0
	return p * q * g
k = reduce(solve, a)
if k == 0:
	print(0)
else:
	print(M // k - M // (k * 2))


from fractions import gcd
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
wa = []
for i in range(n):
	p = a[i]
	f = 0
	while p % 2 == 0:
		p = p // 2
		f += 1
	wa.append(f)
if max(wa) != min(wa):
	print(0)
	exit()
ans = a[0]
for i in range(1, n):
	ans = ans * a[i] // gcd(ans, a[i])
g = ans // 2
kai = m // g
kai = -(-kai // 2)
print(kai)


from functools import reduce

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def lcm(a, b):
	return a // gcd(a, b) * b
(N, M) = map(int, input().split())
As = list(map(int, input().split()))
Bs = [A // 2 for A in As]
lcmB = reduce(lcm, Bs)
for B in Bs:
	if lcmB // B % 2 == 0:
		print(0)
		break
else:
	num = M // lcmB
	print((num + 1) // 2)


from fractions import gcd
(n, m) = [int(x) for x in input().split()]
a_list = [int(x) for x in input().split()]
a_h_list = [a // 2 for a in a_list]
count = set()
for a_h in a_h_list:
	temp = bin(a_h)
	count.add(len(temp) - temp.rfind('1'))
if len(count) == 1:
	temp = 1
	for a_h in a_h_list:
		temp *= a_h // gcd(a_h, temp)
	ans = (m // temp + 1) // 2
else:
	ans = 0
print(ans)


import math

def lcm(a, b):
	return a * b // math.gcd(a, b)

def div2(n):
	return bin(n)[::-1].find('1')
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ans = a[0]
count = div2(a[0])
for i in range(1, len(a)):
	if count != div2(a[i]):
		print(0)
		exit()
	ans = lcm(ans, a[i])
ans //= 2
print((m // ans + 1) // 2)


from math import gcd
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
f = lambda n: 0 if n % 2 else f(n >> 1) + 1
x = f(A[0])
if sum((x != f(a) for a in A)):
	print(0)
	return
A = [a >> x for a in A]
y = 1
for a in A:
	y = y * a // gcd(y, a)
	if y << x - 1 > M:
		print(0)
		return
print((M // (y << x - 1) + 1) // 2)


import math
(N, M) = map(int, input().split())
B = tuple((int(a) // 2 for a in input().split()))
x = B[0]
for i in range(1, N):
	x = x * B[i] // math.gcd(x, B[i])
for b in B:
	if x // b % 2 == 0:
		print(0)
		break
else:
	ans = M // x - M // (2 * x)
	print(ans)


(n, m) = map(int, input().split())
l = sorted(list(set(map(int, input().split()))))
df = l[0]
s = len(bin(df)) - 2
cnt = 0
for i in range(s):
	if df % 2:
		break
	df //= 2
	cnt += 1
l = tuple(map(lambda x: x // 2 ** cnt, l))
for i in l:
	if i % 2 == 0:
		print(0)
		exit()

def gcd(a, k):
	if k:
		return gcd(k, a % k)
	return a
an = l[0]
for i in l:
	an = an * i // gcd(an, i)
print(-(-(m // (an * 2 ** (cnt - 1))) // 2))


from fractions import gcd
from math import ceil
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
c = len(bin(a[0])) - bin(a[0]).rfind('1')
for i in range(1, n):
	if c != len(bin(a[i])) - bin(a[i]).rfind('1'):
		print(0)
		exit()
g = a[0]
for i in range(n - 1):
	g = g // gcd(g, a[i + 1]) * (a[i + 1] // gcd(g, a[i + 1])) * gcd(g, a[i + 1])
g //= 2
print(ceil(m // g / 2))


from fractions import gcd
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
lcm = a[0] // 2
for x in a:
	x //= 2
	g = gcd(lcm, x)
	if lcm // g % 2 != x // g % 2:
		print(0)
		exit()
	lcm = lcm * x // g
print((m // lcm + 1) // 2)


from fractions import gcd
from functools import reduce
(n, m) = map(int, input().split())
a = [int(i) for i in input().split()]
c = 1
while a[0] % 2 == 0:
	a[0] //= 2
	c *= 2
a[0] *= c
for ai in a[1:]:
	if ai % c or ai // c % 2 == 0:
		print(0)
		break
else:
	lcm = reduce(lambda x, y: x * y // gcd(x, y), a) // 2
	print(m // lcm - m // (2 * lcm))


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in a:
	b.append(i // 2)
import fractions
l = 1
for i in b:
	d = fractions.gcd(i, l)
	l = i * l // d
	if l > m:
		print(0)
		sys.exit()
for i in b:
	if l // i % 2 == 0:
		print(0)
		sys.exit()
x = m // l
if x % 2 == 0:
	print(x // 2)
else:
	print(x // 2 + 1)


from functools import reduce
(N, M) = list(map(int, input().split()))
As = list(map(int, input().split()))
Bs = [A // 2 for A in As]

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def lcm(a, b):
	return a // gcd(a, b) * b
nums = []
for B in Bs:
	num = 0
	while B % 2 == 0:
		B //= 2
		num += 1
	nums.append(num)
if len(set(nums)) != 1:
	ans = 0
else:
	L = reduce(lcm, Bs)
	ans = M // L - M // (2 * L)
print(ans)


from math import gcd
from functools import reduce
(n, m) = map(int, input().split())
a = list(map(int, input().split()))

def lcm(a, b):
	return a * b // gcd(a, b)
a = [i // 2 for i in a]
l = reduce(lcm, a)
if any((l // i % 2 == 0 for i in a)):
	print(0)
	return
print(-(-(m // l) // 2))


from functools import reduce
import math

def lcm(x, y):
	return x * y // math.gcd(x, y)

def lcm_list(numbers):
	return reduce(lcm, numbers, 1)
(N, M) = list(map(int, input().split()))
A = list(map(int, input().split()))
A = [a // 2 for a in A]
count_div_2 = None
for a in A:
	cnt = 0
	while a % 2 == 0:
		a //= 2
		cnt += 1
	if count_div_2 is None:
		count_div_2 = cnt
	elif cnt != count_div_2:
		print(0)
		return
my_lcm = lcm_list(A)
if my_lcm > M:
	print(0)
	return
tmp = M // my_lcm
ans = (tmp + 1) // 2
print(ans)


def main():
	(N, M) = map(int, input().split())
	A = tuple(map(int, input().split()))
	ans = count(A, N, M)
	print(ans)

def count(A, N, M):
	t = hMt(A[0])
	B = [A[0] // 2 ** t]
	for val in A[1:]:
		if hMt(val) != t:
			ans = 0
			return ans
		B.append(val // 2 ** t)
	T = nlcm(B)
	MdivT = M // 2 ** (t - 1) // T
	ans = countodd(MdivT)
	return ans

def countodd(num):
	if num % 2 == 0:
		ans = num // 2
	else:
		ans = num // 2 + num % 2
	return ans

def nlcm(A):
	LCM = A[0]
	for val in A[1:]:
		LCM = lcm(LCM, val)
	return LCM

def gcm(a, b):
	abtuple = (a, b)
	abmin = min([0, 1], key=lambda x: abtuple[x])
	remainder = abtuple[1 - abmin] % abtuple[abmin]
	if remainder == 0:
		return abtuple[abmin]
	return gcm(abtuple[abmin], remainder)

def lcm(a, b):
	prod = a * b
	ans = prod // gcm(a, b)
	return ans

def hMt(num):
	ans = 0
	tmp = num
	while tmp % 2 == 0:
		tmp = tmp // 2
		ans += 1
	return ans
main()


import sys
(N, M) = list(map(int, input().split()))
A = list(map(int, input().split()))
a = []
for i in A:
	i = i // 2
	a.append(i)

def gcd(p, q):
	(p, q) = (max(p, q), min(p, q))
	while q != 0:
		(p, q) = (q, p % q)
	return p

def lcm(p, q):
	return p * q // gcd(p, q)

def aaa(i):
	count = 0
	while i % 2 == 0:
		i = i // 2
		count += 1
	return count
max_num = a[0]
aa = aaa(a[0])
for i in a:
	max_num = lcm(i, max_num)
	if aa != aaa(i):
		print(0)
		return
print((M // max_num + 1) // 2)


import sys
(N, M) = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a // gcd(a, b) * b
tx = 1
for a in A:
	tx = lcm(tx, a)
B = []
for a in A:
	B.append(tx // a)
for b in B:
	if b % 2 == 0:
		print(0)
		sys.exit()
ans = (M // (tx // 2) + 1) // 2
print(ans)


from fractions import gcd

def lcm(p, q):
	return p * q // gcd(p, q)
(N, M) = map(int, input().split())
a = [int(i) // 2 for i in input().split()]
x = 1
for i in range(N):
	x = lcm(x, a[i])
for i in range(N):
	if x // a[i] % 2 == 0:
		print(0)
		exit()
num = M // x
print(num // 2 if num % 2 == 0 else num // 2 + 1)


import fractions
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
t = 1
while A:
	b = 0
	for i in range(N):
		A[i] = int(A[i] / 2)
		if A[i] % 2 == 1:
			b += 1
	if b == N:
		break
	elif 0 < b < N:
		t = 0
		break
	else:
		t += 1
if t == 0:
	print(0)
else:
	ans = A[0]
	for i in range(1, N):
		ans = ans * A[i] // fractions.gcd(ans, A[i])
	ans = min(ans, M + 1)
	c = int(M / 2 ** (t - 1) / ans)
	d = int(M / 2 ** t / ans)
	print(c - d)


judge = 0
(N, M) = map(int, input().split())
import fractions
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, N):
	ans = ans * a[i] // fractions.gcd(ans, a[i])
for j in a:
	if ans // j % 2 == 0:
		judge = 1
		sss = 0
		break
if judge == 0 and M - ans // 2 < 0:
	sss = 0
elif judge == 0 and M - ans // 2 >= 0:
	sss = (M - ans // 2) // ans + 1
print(sss)


from functools import reduce
from fractions import gcd

def lcm(a, b):
	return a * b // gcd(a, b)
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = [n // 2 for n in a]
l = reduce(lcm, b)
for i in range(n):
	if l // b[i] % 2 == 0:
		print(0)
		break
else:
	print(m // l // 2 + m // l % 2)


(N, M) = map(int, input().split())
A = list(map(int, input().split()))

def gcd(a, b):
	if a < b:
		(a, b) = (b, a)
	while a % b > 0:
		(a, b) = (b, a % b)
	return b

def lcd(a, b):
	return a * b // gcd(a, b)
L = 1
cur = -1
for i in range(len(A)):
	A[i] //= 2
	p = A[i]
	c = 0
	while p % 2 == 0:
		p //= 2
		c += 1
	if cur != -1:
		if c != cur:
			print(0)
			exit(0)
	cur = c
	L = lcd(L, A[i])
ans = M // (L * 2)
ans += M % (L * 2) // L
print(ans)


from fractions import gcd
import sys
input = sys.stdin.buffer.readline

def f(x):
	cnt = 0
	while x % 2 == 0:
		x //= 2
		cnt += 1
	return cnt
(n, m) = map(int, input().split())
a = list(set([int(i) // 2 for i in input().split()]))
b = f(a[0])
for i in a:
	if f(i) != b:
		print(0)
		exit()
l = 1
for i in a:
	l = l * i // gcd(l, i)
print((m // l + 1) // 2)


import fractions
import math
(N, M) = list(map(int, input().split()))
a = list(map(int, input().split()))
z = a[0]
for x in a[1:]:
	g = fractions.gcd(z, x)
	l = z / g
	m = x / g
	if l % 2 == 1 and m % 2 == 1:
		z = l * m * g
	else:
		print(0)
		exit()
print(round((M + 1) / z))


from fractions import gcd
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = []
lcm = 1
for i in a:
	b.append(i // 2)
for i in b:
	lcm = lcm // gcd(lcm, i) * i
ans = m // lcm
sum = 0
for i in b:
	if lcm // i % 2 == 1:
		sum += 1
if sum != len(a):
	print(0)
elif ans % 2 == 1:
	print((ans + 1) // 2)
else:
	print(ans // 2)


import sys
import fractions
sys.setrecursionlimit(10 ** 9)
(n, m) = map(int, input().split())
alist = list(map(int, input().split()))
alist = list(set(alist))
n = len(alist)

def sks(n):
	global alist
	if n == 1:
		return alist[0]
	else:
		tmp = sks(n - 1)
		return tmp * alist[n - 1] // fractions.gcd(tmp, alist[n - 1])
sk = sks(n)
gomi = sk // 2
for a in alist:
	if (gomi - a // 2) % a != 0:
		print(0)
		sys.exit()
print(int((m + gomi) // sk))


def gcd(a, b):
	if a < b:
		return gcd(b, a)
	while b > 0:
		(a, b) = (b, a % b)
	return a
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
x = 1
for i in range(n):
	b = a[i] // 2
	x = x * b // gcd(x, b)
if any((2 * x // y % 2 == 0 for y in a)):
	print(0)
	quit()
print((m - x) // (2 * x) + 1)


from fractions import gcd

def lcm_base(x, y):
	return x * y // gcd(x, y)

def lcm(numbers):
	x = numbers[0]
	for y in numbers:
		x = lcm_base(x, y)
	return x
(N, M) = list(map(int, input().split()))
aaa = list(map(int, input().split()))
a = aaa[0]
cnt = 0
while a % 2 == 0:
	cnt += 1
	a //= 2
for a in aaa:
	if a % 2 ** cnt != 0 or a % 2 ** (cnt + 1) == 0:
		print(0)
		return
bbb = [a // 2 for a in aaa]
lc = lcm(bbb)
(q, r) = divmod(M // lc, 2)
print(q + r)


from math import gcd

def lcm(a, b):
	return a * b // gcd(a, b)

def lcm_g(A):
	ret = 1
	for a in A:
		ret = lcm(ret, a)
	return ret

def is_hcm(x, A):
	for i in range(N):
		if x % A[i] != A[i] // 2:
			return False
	return True
(N, M) = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
l = lcm_g(A)
if is_hcm(l // 2, A):
	ans = (2 * M + l) // (2 * l)
else:
	ans = 0
print(ans)


def lcm(a, b):
	from math import gcd
	return a * b // gcd(a, b)

def solve(N, M, As):
	if sum([a % 2 for a in As]) > 0:
		print(0)
		return
	As = [a // 2 for a in As]
	all_lcm = 1
	for a in As:
		all_lcm = lcm(all_lcm, a)
		if all_lcm > M:
			print(0)
			return
	for a in As:
		if all_lcm // a % 2 == 0:
			print(0)
			return
	from math import ceil
	print(ceil(M // all_lcm / 2))

def __starting_point():
	(N, M) = list(map(int, input().split()))
	As = [int(i) for i in input().split()]
	solve(N, M, As)
__starting_point()


f = lambda : map(int, input().split())
(n, m) = f()
l = list(f())

def g(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
k = 1
for i in l:
	i //= 2
	k = k * i // g(k, i)
	if k // i % 2 < 1 or k > m:
		print(0)
		break
else:
	print(m // k - m // (k * 2))


from fractions import gcd
from functools import reduce
(N, M) = list(map(int, input().split()))
A = list(map(int, input().split()))
Y = reduce(lambda a, b: a * b // gcd(a, b), A)
print(M // (Y // 2) - M // Y if all((Y // a % 2 for a in A)) else 0)


from fractions import gcd

def lcm(x, y):
	return x * y // gcd(x, y)
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ha = [x // 2 for x in a]
c = ha[0]
for d in ha[1:]:
	l = lcm(c, d)
	if not (l // c % 2 and l // d % 2):
		print(0)
		exit()
	c = l
print((m + c) // (c * 2))


def GCM(x, y):
	if x % y == 0:
		return y
	else:
		return GCM(y, x % y)
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
count2 = [0 for i in range(N)]
for i in range(N):
	a = A[i]
	while a % 2 == 0:
		count2[i] += 1
		a = a // 2
	A[i] = a
if sum(count2) == count2[0] * N:
	count2 = count2[0]
	buf = 1
	for i in range(N):
		buf = A[i] * buf // GCM(buf, A[i])
	buf *= 2 ** (count2 - 1)
	n = M // buf
	print((n + 1) // 2)
else:
	print(0)


import math
import collections
import sys
input = sys.stdin.readline

def I():
	return int(input())

def MI():
	return list(map(int, input().split()))

def LI():
	return list(map(int, input().split()))

def LI2():
	return [int(input()) for i in range(n)]

def MXI():
	return [[LI()] for i in range(n)]
(n, m) = MI()
A = LI()

def num2(x):
	ans = 0
	while x % 2 == 0:
		x = x // 2
		ans += 1
	return ans
mod = 2 ** num2(A[0])
for i in range(1, n):
	if A[i] % mod != 0:
		print(0)
		return
	if A[i] % mod == 0 and A[i] // mod % 2 == 0:
		print(0)
		return
for i in range(n):
	A[i] //= 2

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def lcm(a, b):
	return a // gcd(a, b) * b
L = A[0]
for i in range(1, n):
	L = lcm(L, A[i])
if L > m:
	an = 0
else:
	an = int((m / L - 1) / 2) + 1
print(an)


import sys
input = sys.stdin.readline
from math import gcd, ceil

def main():
	(N, M) = list(map(int, input().split()))
	A = list([int(x) // 2 for x in input().split()])
	lcm = A[0]
	for i in range(1, N):
		lcm = lcm * A[i] // gcd(lcm, A[i])
	allo = 1
	for i in range(N):
		allo &= lcm // A[i] % 2
	if allo:
		print(ceil(int(M // lcm) / 2))
	else:
		print(0)

def __starting_point():
	main()
__starting_point()


import math
import fractions
from functools import reduce
(n, m) = map(int, input().split())
a = list(map(lambda x: int(x) // 2, input().split()))
t = 0
while all([i % 2 ** (t + 1) == 0 for i in a]):
	t += 1
a = [i // 2 ** t for i in a]
if any([i % 2 == 0 for i in a]):
	print(0)
else:
	b = reduce(lambda x, y: x * (y // fractions.gcd(x, y)), a) * 2 ** t
	print((m // b + 1) // 2)


import fractions
from functools import reduce

def lcm(x, y):
	return x * y // fractions.gcd(x, y)

def lcm_list(numbers):
	return reduce(lcm, numbers, 1)
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
a_2 = list((a[i] // 2 for i in range(n)))
t = lcm_list(a_2)
if not all([t // i % 2 for i in a_2]):
	print(0)
	quit()
p = (m - t) // (2 * t) + 1
print(p)


import math
from functools import reduce

def lcm_base(x, y):
	return x * y // math.gcd(x, y)

def lcm(*numbers):
	return reduce(lcm_base, numbers, 1)
(N, M) = map(int, input().split())
a = list(map(lambda a: int(a) // 2, input().split()))
g = lcm(*a)
if any([g // item % 2 == 0 for item in a]):
	print(0)
else:
	ans = M // g
	ans = max(math.ceil(ans / 2), 0)
	print(ans)


(N, M) = map(int, input().split())
A = list(map(int, input().split()))
s = set()
B = []
for a in A:
	t = a & -a
	s.add(t)
	if len(s) > 1:
		print(0)
		exit()
	B.append(a // t)
from fractions import gcd
l = 1
for b in B:
	l = b * l // gcd(b, l)
x = l * t // 2
ans = M // x - M // (2 * x)
print(ans)


import math

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def lcm(a, b):
	return a * b // gcd(a, b)
(N, M) = [int(i) for i in input().split()]
A = [int(i) // 2 for i in input().split()]
lcm_A = 1
for a in A:
	lcm_A = lcm(lcm_A, a)
	if lcm_A // a % 2 == 0:
		print(0)
		break
else:
	print(math.ceil(M // lcm_A / 2))


(n, m, *a) = map(int, open(0).read().split())
c = [bin(i)[::-1].index('1') for i in a]
if sum(c) != c[0] * n:
	print(0)
	exit()
from fractions import *
b = a[0]
for i in a:
	b = i * b // gcd(i, b)
	if b > 2 * m:
		print(0)
		exit()
print((m - b // 2) // b + 1)


import sys
import fractions

def lcm(a, b):
	return abs(a * b) // fractions.gcd(a, b)
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
c = 2
while a[0] % c == 0:
	c = c * 2
c = c // 2
fail = 0
for i in range(n):
	if a[i] % c != 0:
		fail = 1
	if a[i] % (2 * c) == 0:
		fail = 1
if fail == 1:
	print(0)
	sys.exit()
A = 1
for i in range(n):
	A = lcm(A, a[i])
print(2 * m // A - 2 * m // (2 * A))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = [a[i] // 2 for i in range(n)]
from fractions import gcd
from functools import reduce

def lcm(x, y):
	return x * y // gcd(x, y)
x = reduce(lcm, b, 1)
y = reduce(lcm, a, 1)
if x > m:
	print(0)
else:
	z = (m - x) // y + 1
	for i in b:
		if x // i % 2 == 0:
			z = 0
			break
	print(z)


(N, M) = map(int, input().split())
A = list(map(lambda x: int(x) // 2, input().split()))
import math

def lcm(x, y):
	return x // math.gcd(x, y) * y

def pow2(x):
	ret = 0
	while x % 2 == 0:
		ret += 1
		x //= 2
	return ret
P = []
for a in A:
	P.append(pow2(a))
if len(set(P)) != 1:
	print(0)
else:
	m = 1
	for a in A:
		m = lcm(m, a)
	print(-(-(M // m) // 2))


import math
(n, m) = map(int, input().split())
al = list(map(int, input().split()))
twos = set()
for c in al:
	(temp, tempc) = (0, c)
	while tempc % 2 == 0:
		tempc //= 2
		temp += 1
	twos.add(temp)
if len(twos) > 1:
	print(0)
else:
	lcmv = al[0]
	for i in range(1, n):
		lcmv = lcmv * al[i] // math.gcd(lcmv, al[i])
	print(max(0, 1 + (m - lcmv // 2) // lcmv))


from fractions import gcd
(n, m) = map(int, input().split())
a = list(map(lambda x: int(x) // 2, input().split()))

def lcm(x, y):
	return x * y // gcd(x, y)

def f(x):
	cnt = 0
	while x % 2 == 0:
		x //= 2
		cnt += 1
	return cnt
r = set([f(i) for i in a])
if len(r) != 1:
	print(0)
	exit()
T = 1
for i in range(n):
	T = lcm(T, a[i])
ans = -(-(m // T) // 2)
c = T
print(ans)


(N, M) = map(int, input().split())
A = list(set(map(lambda x: int(x) // 2, input().split())))

def gcd(x, y):
	return x if y == 0 else gcd(y, x % y)

def lcm(x, y):
	return x * y // gcd(x, y)
l = A[0]
for a in A[1:]:
	l = lcm(l, a)
ans = (M // l + 1) // 2
for a in A[1:]:
	if l // a % 2 == 0:
		ans = 0
		break
print(ans)


from fractions import gcd
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
	a[i] //= 2
a = sorted(set(a))[::-1]
n = len(a)
b = a[0]
d = a[0]
e = a[0]
ans = m
for i in range(n - 1):
	b = gcd(d, a[i + 1])
	d = d * a[i + 1] // b
	e = gcd(e, a[i + 1])
c = m // d - m // (2 * d)
for i in range(n):
	a[i] //= e
	if a[i] % 2 == 0:
		c = 0
		break
print(c)


import fractions
import math
from functools import reduce

def lcm_base(x, y):
	return x * y // fractions.gcd(x, y)

def lcm(*numbers):
	return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
	return reduce(lcm_base, numbers, 1)
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = lcm_list(map(lambda x: x // 2, a))
swt = 0
for i in range(n):
	if 0 == b // (a[i] // 2) % 2:
		swt = 1
		break
if 0 == swt:
	print(math.ceil(m // b / 2))
else:
	print(0)


import math
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
pow2 = 0
while A[0] % 2 == 0:
	A[0] //= 2
	pow2 += 1
for i in range(1, N):
	cnt = 0
	while A[i] % 2 == 0:
		A[i] //= 2
		cnt += 1
	if cnt != pow2:
		print(0)
		return
LCM = 2 ** max(0, pow2 - 1)
for i in range(N):
	LCM = LCM * A[i] // math.gcd(LCM, A[i])
ans = M // LCM
print((ans + 1) // 2)


import sys

def gcd(x, y):
	if x % y == 0:
		return y
	return gcd(y, x % y)
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
cur = a[0]
for x in a[1:]:
	g = gcd(cur, x)
	if cur // 2 % g != x // 2 % g:
		print(0)
		sys.exit(0)
	else:
		cur = cur // g * x
	if cur > m * 2:
		print(0)
		sys.exit(0)
print((m + cur // 2) // cur)


from fractions import gcd
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
lcm = A[0] // 2
for x in A:
	x //= 2
	g = gcd(lcm, x)
	if lcm // g % 2 != x // g % 2:
		print(0)
		exit()
	lcm = lcm * x // g
print((M // lcm + 1) // 2)


import math

def lcm(x, y):
	return x * y // math.gcd(x, y)
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
a = l[0] // 2
for i in range(n - 1):
	a = lcm(a, l[i + 1] // 2)
ok = True
for i in range(n):
	if a // (l[i] // 2) % 2 != 1:
		ok = False
		break
ans = 0
if ok:
	ans = (m // a + 1) // 2
print(ans)


from math import gcd
import sys

def lcm(x, y):
	return x * y // gcd(x, y)

def count(x):
	res = 0
	while True:
		if x % 2 == 0:
			res += 1
			x //= 2
		else:
			break
	return res
(n, m) = list(map(int, input().split()))
A = list(map(int, input().split()))
A = list(set(A))
n = len(A)
A.sort(reverse=True)
temp = A[0]
for i in range(1, n):
	if count(A[i]) != count(temp):
		print(0)
		return
	else:
		temp = lcm(temp, A[i])
ans = m // (temp // 2) - m // temp
print(ans)


(n, m) = map(int, input().split())
A = [int(i) // 2 for i in input().split()]

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def div2(x):
	ret = 0
	while x % 2 == 0:
		ret += 1
		x //= 2
	return ret
s = div2(A[0])
chk = True
mul = A[0]
for i in range(1, n):
	if s != div2(A[i]) or mul > m:
		chk = False
	else:
		mul = mul * A[i] // gcd(mul, A[i])
if not chk:
	print(0)
else:
	print(m // mul - m // (mul * 2))


import math
(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
if n == 1:
	a1 = a[0] // 2
	ans_m = m // a1
	if ans_m == 0:
		print(0)
	else:
		print((ans_m - 1) // 2 + 1)
else:
	x = a[0]
	ch = 0
	ch1 = 0
	while x % 2 == 0:
		x = x // 2
		ch += 1
	dob = 2 ** ch
	for i in a:
		if i % dob == 0 and i % (dob * 2) != 0:
			ch1 += 1
	if ch1 != n:
		print(0)
	else:
		ans = a[0] // 2
		for j in range(1, n):
			ans = ans * (a[j] // 2) // math.gcd(ans, a[j] // 2)
		ans_m = m // ans
		if ans_m == 0:
			print(0)
		else:
			print((ans_m - 1) // 2 + 1)


from fractions import gcd
from functools import reduce

def lcm(a, b):
	return a * b // gcd(a, b)
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
lh = list(map(lambda x: x // 2, l))
lcm = reduce(lcm, lh)
res = 0
times = [lcm // x % 2 == 1 for x in lh]
if all(times):
	res = (m // lcm + 1) // 2
print(res)


import fractions
(N, M) = map(int, input().split())
A = list(map(int, input().split()))

def lcm(x, y):
	return x * y // fractions.gcd(x, y)

def kn(h):
	l = 0
	while h % 2 == 0:
		h = h // 2
		l += 1
	return l
k = 1
flag = kn(A[0] // 2)
for a in A:
	a //= 2
	k = lcm(k, a)
	if flag != kn(a):
		print(0)
		exit()
print(int(M // k // 2 + M // k % 2))


(N, M) = list(map(int, input().split()))
A = list(map(int, input().split()))
from fractions import gcd

def two(n):
	ans = 0
	while n % 2 == 0:
		n //= 2
		ans += 1
	return ans

def multi_lcm(A):
	ans = A[0]
	for a in A:
		ans *= a // gcd(ans, a)
	return ans

def solve(N, M, A):
	ans = 0
	num_two = len(set(map(two, A)))
	if num_two != 1:
		return 0
	l = multi_lcm(A)
	ans = (M + l // 2) // l
	return ans
print(solve(N, M, A))


from fractions import gcd
from functools import reduce
(N, M) = map(int, input().split())
(*a,) = map(int, input().split())
lcm = reduce(lambda x, y: x * y // gcd(x, y), a)
for i in map(lambda x: lcm // x, a):
	if i % 2 == 0:
		print(0)
		break
else:
	start = lcm // 2
	print((M - start) // lcm + 1)


import fractions
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
g = a[0]
flag = 1
x = 0
y = 0
for i in range(n - 1):
	z = fractions.gcd(g, a[i + 1])
	x = g / z
	y = a[i + 1] / z
	if x % 2 == 1 and y % 2 == 1:
		g = x * y * z
	else:
		print(0)
		flag = 0
		break
if flag == 1:
	print(round((m + 1) / g))


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
LCM = 1
for i in A:
	i = i // 2
	LCM = lcm(i, LCM)
for i in A:
	i = i // 2
	if LCM // i % 2 == 0:
		print(0)
		exit()
ans = (M // LCM + 1) // 2
print(ans)


from fractions import gcd
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
l = 1
num = a[0]
bin = 1
while num % 2 == 0:
	bin *= 2
	num //= 2
for num in a:
	l = l * num // 2 // gcd(l, num // 2)
	if num % bin != 0 or num % (bin * 2) == 0:
		print(0)
		exit()
print((m + l) // (2 * l))


from functools import reduce

def main():
	(N, M) = map(int, input().split())
	(*A,) = map(int, input().split())
	A = list(set(A))
	N = len(A)
	B = [A[i] // 2 for i in range(N)]

	def factorize(n):
		out = []
		i = 2
		while i == 2:
			if n % i == 0:
				out.append(i)
				n //= i
			else:
				i += 1
			if n == 1:
				break
			if i > int(n ** 0.5 + 3):
				out.append(n)
				break
		return out
	ord_list = [len(factorize(B[i])) for i in range(N)]
	if len(set(ord_list)) != 1:
		print(0)
		return

	def gcd(a, b):
		if b == 0:
			return a
		return gcd(b, a % b)

	def lcm(a, b):
		return a * b // gcd(a, b)
	LCM = reduce(lcm, B)
	print((M // LCM + 1) // 2)

def __starting_point():
	main()
__starting_point()


def lcm(a, b):
	return a // gcd(a, b) * b

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def cnt(a):
	res = 0
	while a and a % 2 == 0:
		a //= 2
		res += 1
	return res
(n, m) = map(int, input().split())
A = list(map(int, input().split()))
l = 1
c = cnt(A[0])
for a in A:
	if cnt(a) != c or c == 0:
		print(0)
		return
	else:
		l = lcm(l, a // 2)
d = m // l
print((d + 1) // 2)


(n, m) = map(int, input().split())
a = [int(x) // 2 for x in input().split()]
import fractions

def lcm(x, y):
	return x * y // fractions.gcd(x, y)
import math
lcm1 = 1
for i in a:
	lcm1 = lcm(lcm1, i)
	if lcm1 // i % 2 == 0:
		print(0)
		exit()
print(math.ceil(m // lcm1 / 2))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
import math

def lcm(x, y):
	return x * y // math.gcd(x, y)
x = 1
for i in range(n):
	x = lcm(x, a[i] // 2)
power = [0] * n
for i in range(n):
	while a[i] % 2 == 0:
		a[i] //= 2
		power[i] += 1
if power.count(power[0]) == n:
	print((m + x) // (2 * x))
else:
	print(0)


import numpy as np
import sys

def main():
	(N, M) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	A_double = list([x // 2 for x in A])
	mini_multi = int(np.lcm.reduce(A_double))
	res = M // mini_multi
	for i in A_double:
		if mini_multi // i % 2 == 0:
			print(0)
			return
	if res % 2 != 0:
		res += 1
	print(res // 2)

def __starting_point():
	main()
__starting_point()


import copy

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def lcm(a, b):
	return a // gcd(a, b) * b

def main():
	(n, m) = map(int, input().split())
	A = set([int(x) for x in input().split()])
	a_lcm = 1
	for a in A:
		a_lcm = lcm(a_lcm, a)
		if a_lcm / 2 > m:
			print(0)
			return
	for a in A:
		if a_lcm / 2 % a == 0:
			print(0)
			return
	ans = int((m - a_lcm / 2) // a_lcm) + 1
	print(ans)

def __starting_point():
	main()
__starting_point()


(n, m) = map(int, input().split())
l = list(map(int, input().split()))

def gcd(x, y):
	return x if y == 0 else gcd(y, x % y)

def lcm(x, y):
	return x * y // gcd(x, y)
ans = 1
tf = True
for i in l:
	i //= 2
	ans = lcm(ans, i)
	if ans // i % 2 == 0 or ans > m:
		print(0)
		tf = False
		break
if tf == True:
	print(m // ans - m // (ans * 2))