//#include
//#include
//using namespace std;
//
//const int maxn = 11;
//int n,p[maxn],hashtable[maxn]={false},count=0;
//
//void generateP(int index){
// if(index == n+1){
// bool flag=true;
// for(int i=1;i<=n;i++)
// for(int j=i+1;j<=n;j++)
// if(abs(i-j)==abs(p[i]-p[j]))
// flag=false;
//
// if(flag) count++;
// return;
// }
//
// for(int i=1;i<=n;i++){
// if(!hashtable[i]){
// p[index]=i;
// hashtable[i]=true;
// generateP(index+1);
// hashtable[i]=false;
// }
// }
//}
//
//int main(){
// scanf("%d",&n);
// generateP(1);
// printf("%d",count);
// return 0;
//}
include
include
using namespace std;
const int maxn=10010;
int n,p[maxn],hashtable[maxn]={false},count=0;
void generateP(int index){
if(index == n+1){
count++;
return;
}
for(int i=1;i<=n;i++){
if(!hashtable[i]){
bool flag=true;
for(int pre=1;pre<index;pre++){
if(abs(index-pre)==abs(i-p[pre])){
flag=false;
break;
}
}
if(flag){
p[index]=i;
hashtable[i]=true;
generateP(index+1);
hashtable[i]=false;
}
}
}
}
int main(){
scanf("%d",&n);
generateP(1);
printf("%d",count);
return 0;
}