#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
long long n,m,f[8000010],a[880];
int main()
{
freopen("examone.in","r",stdin);
freopen("examone.out","w",stdout);
scanf("%lld%lld",&n,&m);
int x,y;
for (int i=1;i<=m;++i)
{
scanf("%d%d",&x,&y);
a[x]=a[x]|(1<<(y-1));
}
int tot=1<<n;
f[0]=1;
for (int i=1;i<=tot-1;++i)
{
int k=i,num=0;
while (k) {
k-=(k&-k);
num++;
}
k=i&(~a[num]);
while (k) {
f[i]+=f[i^(k&-k)];
k-=(k&-k);
}
}
printf("%lld",f[tot-1]);
return 0;
}