import java.util.Scanner;
/**
* @author: 梁树鹏
*/
public class luogu2_7_1219 {
/*
* 举例说明:a[]
* a为存放每一行,皇后的位置,a[1]=6,代表第一行的皇后放在位置6,以此类推bcd
*
*/
static int a[] = new int[1000];//a存放每一行皇后的位置
static int b[] = new int[1000];//b代表每一列,是否被放置了皇后
static int c[] = new int[1000];//c存左下到右上的对角线(行+列的和相同)
static int d[] = new int[1000];//d存左上到右下的对角线(行-列的差相同),注意有负数的情况,请看下面
static int n = 0,s = 0;
public static void main(String args[]) {
Scanner scanner = new Scanner(System.in);
n = scanner.nextInt();
//从第一个皇后开始搜索,即第一行
search(1);
System.out.println(s);
scanner.close();
}
//用于输出的函数
public static void print(){
int i;
s++;
if(s