#include <bits/stdc++.h>
using namespace std;
long long f1[250009];
void fact(long long mod) {
  f1[0] = 1;
  for (int i = 1; i < 250003; i++) f1[i] = (f1[i - 1] * i * 1ll) % mod;
}
int main() {
  long long n, m;
  cin >> n >> m;
  fact(m);
  long long sum1 = 0ll;
  for (int i = 1; i <= n; i++) {
    int y1 = (n - (i - 1));
    long long p1 = (y1 * 1ll) % m;
    p1 = (p1 * f1[y1] * 1ll) % m;
    p1 = (p1 * f1[i] * 1ll) % m;
    sum1 = (sum1 + p1) % m;
  }
  cout << sum1 << endl;
  return 0;
}
