#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<string>
#include<set>
#include<sstream>
using namespace std;
int c[20];
int n;
int ans=0;
void dfs(int row)
{
if(row==n)
{
ans++;
return ;
}
for(int i=0;i<n;i++)
{
int ok=1;
c[row]=i;
for(int j=0;j<row;j++)
{
if(c[row]==c[j]||row+c[row]==j+c[j]||row-c[row]==j-c[j])
{
ok=0;
break;
}
}
if(ok)
{
dfs(row+1);
}
}
}
int main()
{
while(~scanf("%d",&n))
{
dfs(0);
printf("%d\n",ans);
}
return 0;
}
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<string>
#include<set>
#include<sstream>
using namespace std;
int c[20];
int n;
int ans=0;
void dfs(int row)
{
if(row==n)
{
ans++;
return ;
}
for(int i=0;i<n;i++)
{
int ok=1;
c[row]=i;
for(int j=0;j<row;j++)
{
if(c[row]==c[j]||row+c[row]==j+c[j]||row-c[row]==j-c[j])
{
ok=0;
break;
}
}
if(ok)
{
dfs(row+1);
}
}
}
int main()
{
while(~scanf("%d",&n))
{
dfs(0);
printf("%d\n",ans);
}
return 0;
}