program MARCH;
var Tourists:array[1..2000] of BOOLEAN;
    answers:array[1..2000] of integer;
    N,P:integer;
    answer:Longint;

procedure Init;
begin
 answer:=0;
 readln(N,P);
 FillChar(Tourists,SizeOf(Tourists),FALSE);
end;

function GetGroups:LongInt;
var am,otg,biggest:integer;
begin
 otg:=0;
 am:=N+1;
 biggest:=answers[N];
 repeat
  repeat
   dec(am);
  until (am=1) or (answers[am-1]>biggest);
  If not(am=1) then
   biggest:=answers[am-1];
  inc(otg);
 until (am=1);
 GetGroups:=otg;
end;

procedure DoGroup(go:integer);
var i:integer;
begin
 If (go<=N) then begin
  for i:=1 to N do begin
   If not(Tourists[i]) then begin
    answers[go]:=i;
    If not(go=N) then begin
     Tourists[i]:=TRUE;
     DoGroup(go+1);
     Tourists[i]:=FALSE;
    end else begin
     If (GetGroups=P) then answer:=answer+1;
    end;
   end;
  end;
 end;
end;

begin
 Init;
 DoGroup(1);
 Writeln(answer mod 1020847);
end.
