import java.util.*; public class Main { static final int MOD = 1000000007; public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); long[] pops = new long[n + 1]; Arrays.fill(pops, -1); pops[0] = 0; pops[n] = pow(2, n) - 1; for (int i = 0; i < k; i++) { long x = sc.nextLong(); if (pops[getPop(x)] != -1) { System.out.println(0); return; } pops[getPop(x)] = x; } long prev = pops[0]; long ans = 1; int count = 0; for (int i = 1; i <= n; i++) { if (pops[i] == -1) { count++; continue; } if ((prev & pops[i]) != prev) { System.out.println(0); return; } ans *= kaijo(count + 1); count = 0; prev = pops[i]; } System.out.println(ans); } static int getPop(long x) { int count = 0; while (x > 0) { count += x % 2; x /= 2; } return count; } static long pow(long x, int p) { if (p == 0) { return 1; } else if (p % 2 == 0) { return pow(x * x, p / 2); } else { return x * pow(x, p - 1); } } static long kaijo(int x) { if (x == 0) { return 1; } else { return x * kaijo(x - 1); } } }