var
   n,k,i,j : longint;
   a : array[0..2000,0..2000] of longint;
begin
   readln(n,k);
   for i:=1 to n do a[i,i]:=1;
   for i:=2 to n do
      for j:=1 to n-1 do
         begin
            a[i,j]:=a[i-1,j-1] + (i-1)*a[i-1,j];
            if a[i,j]>1020847 then a[i,j]:=a[i,j] mod 1020847;
         end;
   writeln(a[n,k]);
end.