program subway;
var
ans,n,p:longint;
procedure ini;
Begin
assign(input,'subway.in');
assign(output,'subway.out');
reset(input); rewrite(output);
readln(n,p); ans:=1;
End;
procedure go;
var
i:longint;
Begin
if p>=n then for i:=1 to n do ans:=(ans*i) mod 10000
else if p<>1 then begin
for i:=1 to p do
ans:=(ans*i) mod 10000;
for i:=1 to n-p do
ans:=(ans*2) mod 10000;
end;
if p=1 then ans:=1;
End;
Begin
ini;
go;
writeln(ans mod 4096);
close(input); close(output);
end.