program lx;
const
filename='put';
inf=filename+'.in';
ouf=filename+'.out';
maxn= ;
var
i,j,k,l,m,n,sum:longint;
a,f:array[1..10000]of longint;
q:array[1..10000]of boolean;
function pan:boolean;
var i:longint;
begin
pan:=true;
for i:=1 to n do
if f[i]=i then
exit(false);
end;
procedure dfs(k:longint);
var i,j:longint;
begin
if k=n+1 then
begin
if pan then inc(sum) end
else
begin
for i:=1 to n do
if q[i] then
begin
q[i]:=false;
f[k]:=i;
dfs(k+1);
q[i]:=true;
end;
end;
end;
begin
assign(input,inf); reset(input);
assign(output,ouf);rewrite(output);
readln(n);
fillchar(q,sizeof(q),true);
sum:=0;
dfs(1);
writeln(sum);
close(input);close(output);
end.