object Main extends App {
	val temp = scala.io.StdIn.readLine
	val N = temp.split(" ")(0).toInt
	val P = temp.split(" ")(1).toInt
	val a = scala.io.StdIn.readLine.split(" ").map(_.toLong % 2L)

	def con(x: Long, y: Long): Long = {
		if(x==y || y==0L) 1L
		else con(x, y-1L)*(x-y+1L)/y
	}

	def pow(x : Long): Long = {
		if(x==0L) 1L
		else 2L*pow(x-1L)
	}

	var t = 0L // 0
	var z = 0L // 1

	for(i<- a){
		if(i==0L) t = t + 1L
		else z = z + 1L
	}

	var test = pow(t)
	var sum = 0L

	if(P==0){
		var q = 0L
		while(z >= q){
			sum = sum + con(z,q)
			q = q + 2L
		}
		test = test*sum
	}else{
		var q = 1L
		while(z >= q){
			sum = sum + con(z,q)
			q = q + 2L
		}
		test = test*sum
	}


	println(test)

}