module mod_fac_mul
    implicit none
    private
    public num, div_prime, init_prime, calc_lcm, print_x,asmbl_lcm
    type term
        integer(8):: fac, mul
    end type
    type num
        integer(8):: n
        type(term), pointer:: p(:)
    end type
    integer(8), allocatable:: prime(:)
    logical, allocatable:: is_prime(:)

contains
    subroutine div_prime(x)
        type(num):: x
        integer(8):: nx
        
        nx = x%n
        do while(nx /= 1)
            call add_prime(x,prime(nx))
            nx = nx / prime(nx)
        end do
        ! call print_x(x,"x")
    end subroutine


    subroutine init_prime(m)
        integer(8):: m, i, j

        allocate(prime(m), is_prime(m))
        is_prime(:) = .true.
        is_prime(1) = .false.
        do i = 2, m
            if (is_prime(i)) then
                prime(i) = i
                do j = 2*i,m,i
                    is_prime(j) = .false.
                    prime(j) = i
                end do
            end if
        end do
        
        ! do i = 1, m
        !     print*, i, prime(i), is_prime(i)
        ! end do
    end subroutine


    subroutine add_prime(x, p)
        type(num):: x
        integer(8):: p
        integer(4):: x_size, i
        
        x_size = size(x%p(:))
        i = 1
        do while(i <= x_size)
            if (x%p(i)%fac == p) then
                x%p(i)%mul = x%p(i)%mul + 1 
                return
            end if
            i = i + 1
        end do

        call append_x(x,p,1_8)
    end subroutine


    subroutine append_x(x,p,m)
        type(num):: x, tmp
        integer(8):: p, m, x_size

        x_size = size(x%p(:))
        allocate(tmp%p(x_size))
        tmp%p(:) = x%p(:)
        deallocate(x%p)
        allocate(x%p(x_size+1))
        x%p(:x_size) = tmp%p(:)
        deallocate(tmp%p)
        x%p(x_size+1)%fac = p
        x%p(x_size+1)%mul = m
    end subroutine


    subroutine print_x(x, word)
        type(num)::x
        integer(4):: i
        character(*):: word
        print'(a," : -----")',word
        print'(" num => ", i0)', x%n
        do i = 1, size(x%p(:))
            print"('     f: ',i0,',  m: ',i0)", x%p(i)%fac, x%p(i)%mul
        end do
    end subroutine


    subroutine calc_lcm(lcm, x)
        type(num):: lcm, x
        integer(4):: i, j
        integer(8):: fac, mul
        logical:: fac_exist

        do i = 1, size(x%p(:))
            fac_exist = .false.
            fac = x%p(i)%fac
            mul = x%p(i)%mul
            j = 1
            do while(j <= size(lcm%p(:)))
                if(lcm%p(j)%fac == fac)then
                    lcm%p(j)%mul = max(lcm%p(j)%mul, mul)
                    fac_exist =.true.
                    exit
                end if
                j = j+1
            end do

            if (.not. fac_exist)then
                call append_x(lcm, fac, mul)
            end if
        end do
    end subroutine


    subroutine asmbl_lcm(x, ix)
        type(num):: x
        integer(8):: ix
        integer(4):: x_size, i

        ix = 1
        x_size = size(x%p(:))

        do i = 1,x_size
            ix = ix*x%p(i)%fac**x%p(i)%mul
            if (ix >= 1000000001) then
                ix = 1000000001
                return
            end if
        end do
    end subroutine
end module


program semi_common_multiple
    use mod_fac_mul
    implicit none
    integer(8):: n, m, i, ilcm
    integer, allocatable:: ia(:)
    type(num), allocatable:: a(:)
    type(num):: lcm
    
    read*, n, m
    allocate(a(n), ia(n))
    read*, ia(:)
    a(:)%n = ia(:)
    do i=1,n
        allocate(a(i)%p(0))
    end do
    a(:)%n = a(:)%n / 2
    call init_prime(maxval(a(:)%n))
    do i=1, n
        call div_prime(a(i))
    end do
    allocate(lcm%p(0))
    do i=1, n
        call calc_lcm(lcm, a(i))
    end do
    ! call print_x(lcm, 'lcm')
    call asmbl_lcm(lcm, ilcm)
    print*, (m/ilcm+1)/2
end program semi_common_multiple