
  var s:array[0..2,0..2000] of longint;
      N,p,k,i:integer;
      j1,j2:integer;

  function minabsmod(a,b:longint):longint;
    begin
      if abs(a)<abs(b) then minabsmod:=a
        else minabsmod:=b;
    end;


    BEGIN
      readln(n,p);
    if (n=1) or (n=2) then writeln(1)
    else
     begin
      s[1,1]:=1;
      s[1,2]:=4;
      s[1,3]:=1;

      if n>3 then
        begin
      k:=3;
      repeat
       j1:=1; j2:=k;
       for i:=1 to k+1 do
        begin
         s[2,i]:=(s[2,i]mod 1020847) +((j1*s[1,i]) mod 1020847);
         s[2,i+1]:=(s[2,i+1]mod 1020847) +((j2*s[1,i]) mod 1020847);
         inc(j1); dec(j2);
        end;
       s[1]:=s[2];
       s[2]:=s[0];
       inc(k);
      until k=n;

    end;

    writeln(s[1,p]);
  end;

    END.