import Data.List
import Data.Int

main = do
   [n,m] <- map (read) . words <$> getLine :: IO [Int64]
   as <- map (half . read) . words <$> getLine :: IO [Int64]
   putStrLn $ show (ans m as)

ans :: Int64 -> [Int64] -> Int64
ans m as = f (foldl1 (lcm1 m) as) m

lcm1 :: Int64 -> Int64 -> Int64 -> Int64
lcm1 m a b
  | lcm a b > m = m+1
  | (orde a) /= (orde b) = m+1 
  | otherwise = lcm a b

half :: Int64 -> Int64
half a = a `div` 2

f :: Int64 -> Int64 -> Int64
f a m = (m + a) `div` (2 * a)

orde :: Int64 -> Int64
orde n 
  | n `mod` 2 == 1 = 0
  | otherwise = orde (n `div` 2) + 1
