import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
import java.util.StringTokenizer;

public class army_sm_fast {
    int n;


    final int FREE = 0;
    final int USED = 1;
    final int IN_A = 2;
    long[] currentAnswer;
    Queue<Integer> queue;

    int[] a;
    boolean[] inSeq;

    void solve() throws IOException {
        n = nextInt();
        int k = nextInt();
        a = new int[k];
        inSeq = new boolean[n];
        for (int i = 0; i < k; i++) {
            a[i] = nextInt() - 1;
            inSeq[a[i]] = true;
        }
        queue = new ArrayDeque<Integer>();
        currentAnswer = new long[(int) (Math.pow(3, n) + 1)];
        Arrays.fill(currentAnswer, -1);
        int start = 0;
        currentAnswer[start] = 1;
        queue.add(start);
        int[] sMask = new int[n];
        int[] armyt = new int[n + 1];
        while (!queue.isEmpty()) {
            int s = queue.poll();
            getMask(sMask, s);
            int sCompleted = getCompleted(sMask);
            long add = currentAnswer[s];
//            System.err.println(" s = " + s +" mask = " + Arrays.toString(sMask) + " sCompleted = " + sCompleted + " ans = " + add);

            int armytLen = 0;
            for (int i = 0; i < n; i++) {
                if (sMask[i] == IN_A) {
                    armyt[armytLen++] = i;
                }
            }
            armyt[armytLen++] = n + 1;
//            armyt = Arrays.copyOf(armyt, armytLen);
//            System.err.println(" armyt = " + Arrays.toString(armyt));
            int j = 0;
            for (int i = 0; i < n; i++) {
                if (sMask[i] != FREE) {
                    continue;
                }
                if (inSeq[i] && a[sCompleted] != i) {
                    continue;
                }
                while (!((j == 0 || armyt[j - 1] < i) && i < armyt[j])){
                    j++;
                }
                {
                    assert ((j == 0 || armyt[j - 1] < i) && i < armyt[j]);
                    if (armyt[j] != n + 1) {
                        assert sMask[armyt[j]] == IN_A;
                        sMask[armyt[j]] = USED;
                    }
                    assert sMask[i] == FREE;
                    sMask[i] = IN_A;
                    int newState = assembly(sMask);
//                        System.err.println("   to  s = " + newState +" mask = " + Arrays.toString(sMask) + " sCompleted = " + getCompleted(sMask));
                    if (currentAnswer[newState] == -1) {
                        currentAnswer[newState] = 0L;
                        queue.add(newState);
                    }
                    currentAnswer[newState] += add;
                    sMask[i] = FREE;
                    if (armyt[j] != n + 1) {
                        sMask[armyt[j]] = IN_A;
                    }

                }

            }
        }
        long ans = 0;
        int[] mask = new int[n];
        int pCount = 0;
        for (int j = 0; j < currentAnswer.length; j++) {
            if (currentAnswer[j] == -1) {
                continue;
            }
            pCount++;
            getMask(mask, j);
            int sCompleted = getCompleted(mask);
            if (sCompleted != a.length) {
                continue;
            }
            boolean completed = true;
            int inLasCnt = 0;
            for (int i : mask) {
                completed &= i != FREE;
                if (i == IN_A) {
                    inLasCnt++;
                }
            }
            if (completed && sCompleted == a.length && inLasCnt == a.length) {
                ans += currentAnswer[j];
            }
        }
        System.out.println(ans);
        out.println(ans);
    }

    private int getCompleted(int[] sMask) {
        int cnt = 0;
        for (int i = sMask.length - 1; i >= 0; i--) {
            if (inSeq[i] && sMask[i] != FREE) {
                cnt++;
            }
        }
        return cnt;
    }

    private void getMask(int[] sMask, int s) {
        for (int i = sMask.length - 1; i >= 0; i--) {
            sMask[i] = s % 3;
            s /= 3;
        }
    }

    private int assembly(int[] mask) {
        int res = 0;
        for (int i : mask) {
            res = res * 3 + i;
        }
        return res;
    }

    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;

    void run() throws IOException {
        br = new BufferedReader(new FileReader("army.in"));
        out = new PrintWriter("army.out");
        solve();
        out.close();
    }

    int nextInt() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return Integer.parseInt(st.nextToken());
    }

    public static void main(String[] args) throws IOException {
        long start = System.currentTimeMillis();
        new army_sm_fast().run();
        System.err.println("time = " + (System.currentTimeMillis() - start));
    }

}
