var
n,k,s,i:integer;
function fact(n1:longint):longint;
var i,s:longint;
begin
s:=1;
for i:=1 to n1 do S:=(s*i) mod 1020847;
fact:=s;
end;
function multyply(a,b:longint):longint;
begin
multyply:=(a*b) mod 1020847;
end;
begin
readln(n,k);
if k=1 then begin
            writeln(fact(n-1));
            halt(0);
            end;
if n-k=1 then begin
              writeln(multyply(k,k-1));
              halt(0);
              end;
if n=k then begin
            writeln(1);
            halt(0);
            end;
s:=multyply(k,k-1);
for i:=k+1 to n do s:=multyply(s,i);
writeln(s);
end.
