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

public class army_sm_bruteforce_slow {
    int n;

    int[] a;

    boolean[] used;
    boolean[] inSeq;
    long ans = 0;
    int[] p;

    void check() {
        int[] min = new int[n + 1];
        Arrays.fill(min, n + 1);
        for (int i = 0; i < n; i++) {
            int j = 0;
            while (p[i] > min[j]) {
                j++;
            }
            min[j] = p[i];
        }
        if (min[a.length] == n + 1) {
            ans++;
        }
    }

    void gen(int k, int completed) {
        if (k == n) {
            if (completed == a.length) {
                check();
            }
            return;
        }

        for (int i = 0; i < n; i++) {
            if (used[i]) {
                continue;
            }
            if (inSeq[i] && a[completed] != i) {
                continue;
            }
            used[i] = true;
            p[k] = i;
            if (inSeq[i]) {
                gen(k + 1, completed + 1);
            } else {
                gen(k + 1, completed);
            }
            used[i] = false;
        }

    }

    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;
        }
        used = new boolean[n];
        p = new int[n];
        gen(0, 0);

        System.out.println(ans);
        out.println(ans);
    }

    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_bruteforce_slow().run();
        System.err.println("time = " + (System.currentTimeMillis() - start));
    }

}
