import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main ()
{
	int n, p;
	while (readf (" %s %s", &n, &p) > 0)
	{
		readln;
		auto a = readln.split.map !(to !(int)).array;
		auto f = new long [2] [n + 1];
		f[0][0] = 1;
		foreach (i; 0..n)
		{
			foreach (j; 0..2)
			{
				f[i + 1][(j + a[i]) & 1] += f[i][j];
				f[i + 1][j] += f[i][j];
			}
		}
		writeln (f[n][p]);
	}
}
