const maxn = 2000;

var a : array[1..maxn, 1..maxn] of longint;
    i, j, k, l, o, p, m, n : longint;

function min(k1, k2 : longint) : longint;
 begin
  if k1 < k2 then min := k1
             else min := k2;
 end;


begin
 readln(n, k);
 for i := 1 to n do
   begin
    a[i, 1] := 1;
    a[i, i] := 1;
   end;
 for i := 2 to n do
   begin
    if i mod 2 = 0 then p := i div 2
                   else p := (i div 2) + 1;
    for j := 2 to p do
      a[i, j] := (((i - j + 1)*a[i - 1, j - 1] + j * a[i - 1, j])) mod 1020847;
   end;
 writeln(a[n, min(k, n - k + 1)]);
end.
