fun main(args : Array<String>) {
    val (n, p) = readLine()!!.split(" ").map { it.toInt() }
    val aa = readLine()!!.split(" ").map { it.toInt() }
    val ae = aa.count { it % 2 == 0 }
    val ao = aa.count { it % 2 == 1 }

    val eSum = Math.pow(2.0, ae.toDouble()).toLong()

    var ans = 0L
    if (p == 0) {
        for (i in 0..ao step 2) {
            ans += eSum * comb(ao, i)
        }
    } else {
        for (i in 1..ao step 2) {
            ans += eSum * comb(ao, i)
        }
    }

    println(ans)
}

fun comb(n: Int, k: Int): Long {
    if (n == 0 || k == 0) return 1L
    if (k > n / 2) return comb(n, n-k)
    val fact = (2..k).fold(1L) { acc, i -> acc * i }
    return perm(n, k) / fact
}

fun perm(n: Int, k: Int): Long {
    require(n > 0 && k >= 0)
    return (n - k + 1 .. n).fold(1L) { acc, i -> acc * i }
}