#include <stdio.h>

#define MAXP 2000
#define MOD 1020847

int N, P;

int fak(int n)
{
  int i;
  int ost = 1, st = 1;
  for(i=2; i<=n; i++)
  {
    st*=i;
    if(st> MOD )
    {
     ost*=st% MOD;
     st =1;
    }
  }
  ost*=st;
  ost%= MOD;
  return ost;
}
int main()
{
 scanf("%d%d", &N, &P);
 if(N==P)
  printf("1\n");

 else if(P==1)
  printf("%d\n", fak(N-1));

 else
 {
   printf("%d\n", (  N/P * fak(P) * fak(N-P) ) % MOD );

 }
 return 0;
}



