import functools



import math



@functools.lru_cache()

def combinations(n, r):

    return math.factorial(n) / math.factorial(r) / math.factorial(n - r)





def main():

    n, p = list(map(int, input().split()))

    a = tuple([int(x) % 2 for x in input().split()])



    if n == 1 and a[0] % 2 != p:

        print((0))

        return 0



    t = len(tuple([x for x in a if x == 1]))

    f = n - t



    count = 0



    if p == 0:

        for i in range(t + 1):

            if i % 2 == 0:

                c = 0

                for j in range(f + 1):

                    c += combinations(f, j)

                count += combinations(t, i) * c

    else:

        for i in range(t + 1):

            if i % 2 == 1:

                c = 0

                for j in range(f + 1):

                    c += combinations(f, j)

                count += combinations(t, i) * c



    print((int(count)))



    return 0



if __name__ == '__main__':

    main()

import math





def comb(n, r):

    return math.factorial(n) / math.factorial(r) / math.factorial(n - r)





def main():

    n, p = list(map(int, input().split()))

    a = tuple([int(x) % 2 for x in input().split()])



    if n == 1 and a[0] % 2 != p:

        print((0))

        return 0



    t = len(tuple([x for x in a if x == 1]))

    f = n - t



    f_comb = 0

    for j in range(f + 1):

        f_comb += comb(f, j)



    t_comb = 0

    if p == 0:

        for i in range(t + 1):

            if i % 2 == 0:

                t_comb += comb(t, i)

    else:

        for i in range(t + 1):

            if i % 2 == 1:

                t_comb += comb(t, i)



    print((int(t_comb * f_comb)))



    return 0





if __name__ == '__main__':

    main()

import functools
import math


@functools.lru_cache()
def combinations(n, r):
    return math.factorial(n) / math.factorial(r) / math.factorial(n - r)


def main():
    n, p = list(map(int, input().split()))
    a = tuple([int(x) % 2 for x in input().split()])
    if n == 1 and a[0] % 2 != p:
        print((0))
        return 0
    t = len(tuple([x for x in a if x == 1]))
    f = n - t
    count = 0
    if p == 0:
        for i in range(t + 1):
            if i % 2 == 0:
                c = 0
                for j in range(f + 1):
                    c += combinations(f, j)
                count += combinations(t, i) * c
    else:
        for i in range(t + 1):
            if i % 2 == 1:
                c = 0
                for j in range(f + 1):
                    c += combinations(f, j)
                count += combinations(t, i) * c
    print((int(count)))
    return 0


if __name__ == "__main__":
    main()

import math


def comb(n, r):
    return math.factorial(n) / math.factorial(r) / math.factorial(n - r)


def main():
    n, p = list(map(int, input().split()))
    a = tuple([int(x) % 2 for x in input().split()])
    if n == 1 and a[0] % 2 != p:
        print((0))
        return 0
    t = len(tuple([x for x in a if x == 1]))
    f = n - t
    f_comb = 0
    for j in range(f + 1):
        f_comb += comb(f, j)
    t_comb = 0
    if p == 0:
        for i in range(t + 1):
            if i % 2 == 0:
                t_comb += comb(t, i)
    else:
        for i in range(t + 1):
            if i % 2 == 1:
                t_comb += comb(t, i)
    print((int(t_comb * f_comb)))
    return 0


if __name__ == "__main__":
    main()

-import functools -@functools.lru_cache() -def combinations(n, r): +def comb(n, r): -    count = 0 +    f_comb = 0 +    for j in range(f + 1): +        f_comb += comb(f, j) +    t_comb = 0 -                c = 0 -                for j in range(f + 1): -                    c += combinations(f, j) -                count += combinations(t, i) * c +                t_comb += comb(t, i) -                c = 0 -                for j in range(f + 1): -                    c += combinations(f, j) -                count += combinations(t, i) * c -    print((int(count))) +                t_comb += comb(t, i) +    print((int(t_comb * f_comb)))