#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

int n;	// MAX = 16
int solution_count = 0;
int solution_count_half = 0;
int solution_count_center = 0;
uint32_t col=0, asc=0, desc=0;


bool bCenter=false;
void backtrack(int i) 
{
	int max = n;
	if (i==0) max = (n+1)/2;

    if(i == n) {
		if (bCenter)
			solution_count_center++;
		else
	        solution_count_half++;
        return;
    }
    uint32_t mc, md, ma;
    for(int j=0; j != max; j++) {
		if (i==0 && (n%2)==1 && j==max-1)
			bCenter=true;
    	if (col & (mc = 1<<j)) continue;
    	if (desc & (md = 1 << (i+j))) continue;
    	if (asc & (ma = 1 << (15+i-j))) continue;
    	uint32_t oldc = col, oldd = desc, olda = asc;
        col |= mc;
        desc |= md;
        asc |= ma;
        backtrack(i+1);
        col = oldc;
        desc = oldd;
        asc = olda;
    }
}

int main() 
{ 
	n=14;

	backtrack(0);
	if (n % 2 == 0)
		solution_count = solution_count_half * 2;
	else
		solution_count = solution_count_half * 2 + solution_count_center;
	printf("%d\n", solution_count);

	return 0;
}
