import java.util.Scanner;
public class Main {
static int[] a=new int[9];
static int count=0;
public static boolean check(int n){
for(int i=1;i<n;i++){
if((a[i]==a[n])||(Math.abs(i-n)==Math.abs(a[i]-a[n]))){
return false;
}
}
return true;
}
public static void dfs(int num){
if(num==8){
count++;
return;
}
else{
for(int i=1;i<=8;i++){
a[num+1]=i;
if(check(num+1)){
dfs(num+1);
}
}
}
}
public static void main(String[] args){
//Scanner sc=new Scanner(System.in);
dfs(0);
System.out.println(count);
}
}