#include <stdio.h>
#include <math.h>

long fact(int n) {
   if (n<2) return 1;
   return n*fact(n-1);
}


int check_con(int a[], int n, int c[][2], int k) {
  int pos1, pos2, i, j;

  for (j=0; j < k; j++) {
     pos1 = 0; pos2 = 0;
     for (i=1; i <= n; i++) {
       if (a[i] == c[j][0]) pos1 = i;
       if (a[i] == c[j][1]) pos2 = i;
     }
     if (pos1 >= pos2 && pos1 >0 && pos2 > 0) return 0;
  }
   return 1;

}

int makeperm(int a[], int n, int c[][2], int k, int b, int e) {
   int i, t, temp[n+1];
   if (b==e) {
      return check_con(a, n, c, k );
   } else { /* got to keep going */
      for (i=1; i <= b; i++) { /* copy array to keep for later */
         temp[i] = a[i];
      }
      temp[b+1] = b+1; /* put the next num into the perm */
      t = 0;
      for (i=b+1; i > 0; i--) {  /* shuffle down the element b+1 */
        if (check_con(temp, b+1, c, k) == 1) {
          t = t+ makeperm(temp, n, c, k, b+1, e);
        }
        if (i >= 1) {
        temp[i] = a[i-1];
        temp[i-1] = b+1;
        }
      }
      return t;
   }
}


main () {
 int k, n, i, x, y;
 long result;

 /* Read n and k */
 scanf("%d", &n);
 scanf("%d", &k);

 { int A[n+1], next[n+1], constraint[k][2];

   /* read in the constraints */

   for (i=0; i<=k ; i++) {
     scanf("%d", &x);
     scanf("%d", &y);
     constraint[i][0] = x;
     constraint[i][1] = y;
   }

     A[1] = 1;
     printf("%d\n", makeperm(A, n, constraint, k, 1, n));
 } /* dynamic array declaration section */
}

