import Control.Monad
main = print =<< ((pure count) <*> getInput)

getInts :: IO [Int]
getInts = (pure ((map read) . words)) <*> getLine

getInput :: IO [[Int]]
getInput = replicateM 2 getInts

count :: [[Int]] -> Int
count [[n, m], as]
        | foldl step False bs = 0
        | otherwise = (`div` 2) $ (+) 1 $ div m k
    where bs = map (`div` 2) as
          k = foldl lcm 1 bs
          step a x = a || even (div k x)

