program aa;
var x:array[1..13]of longint;
a,b,c:array[-14..26]of boolean;
i,total,n:longint;
procedure try(i:longint);
var j:longint;
begin
for j:=1 to n do
if a[j]and b[i+j]and c[i-j] then//a,b,c分别判断同一列,同一对角线,另一条对角线是否有点。
begin
x[i]:=j;
a[j]:=false;
b[i+j]:=false;
c[i-j]:=false;
if i<n then try(i+1) else total:=total+1;//i为当前行数,i=n表示已找到一种方法
a[j]:=true;
b[i+j]:=true;
c[i-j]:=true;
end;
end;
begin
fillchar(a,sizeof(a),true);
fillchar(b,sizeof(b),true);
fillchar(c,sizeof(c),true);
readln(n);
total:=0;
try(1);
writeln(total);
end.