#include <bits/stdc++.h>
using namespace std;
long long rr[] = {0, 1, 1, 1, 0, -1, -1, -1};
long long cc[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long mod = 1e9 + 7;
const long long N = 300050;
long long m, fact[N];
void pre() {
  fact[0] = 1;
  for (long long i = 1; i < N; i++) {
    fact[i] = (fact[i - 1] * i) % m;
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long test = 1;
  while (test--) {
    long long n;
    cin >> n >> m;
    pre();
    long long ans = 0;
    for (long long i = 1; i <= n; i++) {
      long long x = fact[n - i + 1] * (n - i + 1) % m;
      x = (x * fact[i]) % m;
      ans = (ans + x) % m;
    }
    cout << ans << '\n';
  }
  return 0;
}
