#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int n,m,ji;
unsigned long long q[2000000],f[2000000];
int w[21];
int main()
{
freopen ("examone.in","r",stdin);
freopen ("examone.out","w",stdout);
cin>>n>>m;
ji=1<<n;
q[0]=1;
f[0]=1;
for (int i=1;i<ji;i++)
f[i]=f[i-1]*2;
for (int i=0;i<m;i++)
{
int a,b;
cin>>a>>b;
w[a]+=f[b-1];
}
for (int i=1;i<f[n];i++)
{
int a=0;
for (int j=i;j;a++,j-=j&-j);
for (int t=i&~w[a];t;t-=t&-t)
q[i]+=q[i^(t&-t)];
}
cout<<q[ji-1];
return 0;
}