program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,p
    integer(int64), allocatable:: a(:)
    integer(int64):: cg,ck,i

    read*, n,p
    allocate(a(n))
    read*, a(:)

    cg=0;ck=0

    do i=1,n
        if (mod(a(i),2) == 0) then
            cg=cg+1
        else
            ck=ck+1
        end if
    end do

    if (p==1) then
        print'(i0)', 2**n - (2**(cg+max(0,ck-1)))
    else
        print'(i0)', (2**(cg+max(0,ck-1)))
    end if
end program name