#include<stdio.h>
#define N 25
#define LL long long
int a[N];
LL f[(1 << 20) + 5];
int n, m;
inline int lowbit(int x){
return x & (- x);
}
int i;
int main(){
FILE *fin, *fout;
fin = fopen("examone.in","r");
fout = fopen("examone.out", "w");
fscanf(fin,"%d %d", &n, &m);
int ms = (1 << n) - 1;
int x, y;
for (i = 1; i <= m; i ++){
fscanf(fin, "%d %d", &x, &y);
a[x] |= (1 << (y - 1));
}
f[0] = 1;
//for (int i = 1; i <= ms; i ++) f[i] = 1;
for (i = 1; i <= ms; i ++){
int temp, num = 0;
for (temp = i; temp ; temp -= lowbit(temp))
num ++;
temp = i & (~ a[num]);
while (temp){
f[i] += f[i ^ lowbit(temp)];
temp -= lowbit(temp);
}
}
fprintf(fout,"%lld\n", f[ms]);
fclose(fin);
fclose(fout);
return 0;
}