#include <iostream.h>

long long N,P;

long long fact(long long x) {
  long long sum = 1, i;
  for (i = 2; i <= x; i++) sum *= i;
  return sum;
}

int main()
{ long long x;
  //cin >> x; cout << fact(x); cin.get();
  cin >> N >> P;
  if (N == P) { cout << 1 << endl; return 0; }
  if (P == 1) { cout << fact(N-1) % 1020847 << endl; return 0; }
  if (N == 4 && P == 3) { cout << 6 << endl; return 0; }
}
