fun main(args: Array<String>) {
    val s = readLine()!!
    val (n, p) = s.split(" ").map(String::toInt)        // 1≤N≤50, P=0,1
    val s2 = readLine()!!
    val a = s2.split(" ").map(String::toInt).toList()   // ≤Ai≤100

    val evenCount = a.count { it % 2 == 0 }
    val oddCount = n - evenCount

    /**
     * a個の中からb個を選ぶ組み合わせの数
     */
    fun combination(a: Int, b: Int): Long {
        var result = 1L
        val max = Math.max(b, a - b)
        val min = Math.min(b, a - b)
        for (i in max + 1..a) {
            result *= i
        }
        for (i in 1..min) {
            result /= i
        }
        return result
    }

    fun sum(a: Int, b: Int, start: Int): Long {
        var result = 0L
        for (i in start..b step 2) {
            result += combination(a, i)
        }
        return result
    }

    /**
     * p=0 食べた数が偶数
     * 偶数は任意 2^evenCount, 奇数は0, 2,..  <=oddCount
     */
    fun even(): Long {
        val ev = 1L.shl(evenCount)
        //val od = oddCount / 2
        return  ev * sum(oddCount, oddCount, 0)
    }

    /**
     * p=1 食べた数が奇数
     * 偶数は任意 2^evenCount, 奇数は1, 3,..  <=oddCount
     */
    fun odd(): Long {
        val ev = 1L.shl(evenCount)
        //val od = (oddCount + 1) / 2
        return  ev * sum(oddCount, oddCount, 1)
    }

    val result = when (p) {
        0 -> even()
        1 -> odd()
        else -> throw Exception()
    }
    println(result)
}
