#include <bits/stdc++.h>
using namespace std;
FILE* in = stdin;
FILE* out = stdout;
const int MAX = 250005;
int n, m;
long long fact[MAX];
void dummy(int len) {
  vector<int> v;
  for (int i = 1; i <= len; i++) v.push_back(i);
  long long ans = 0;
  vector<long long> cnt(len, 0);
  do {
    long long cur = 0;
    for (int l = 0; l < (int)v.size(); l++) {
      int minNum = v[l], maxNum = v[l];
      for (int r = l; r < (int)v.size(); r++) {
        minNum = min(minNum, v[r]);
        maxNum = max(maxNum, v[r]);
        if (r - l == maxNum - minNum) ans++, cur++, cnt[r - l]++;
      }
    }
  } while (next_permutation(v.begin(), v.end()));
}
long long fastPow(long long num, int pwr) {
  long long ret = 1;
  while (pwr) {
    if (pwr & 1) ret = (ret * num) % m;
    num = (num * num) % m;
    pwr >>= 1;
  }
  return ret;
}
long long comb(int n, int k) {
  long long ret = fact[n];
  ret = (ret * fastPow(fact[k], m - 2)) % m;
  ret = (ret * fastPow(fact[n - k], m - 2)) % m;
  return ret;
}
void solve(int len) {
  long long ans = 0;
  for (int i = len; i >= 1; i--) {
    long long cur = fact[len];
    cur = (cur * i) % m;
    cur = (cur * (len - i + 1)) % m;
    cur = (cur * fastPow(comb(len, i), m - 2)) % m;
    ans = (ans + cur) % m;
  }
  fprintf(out, "%lld\n", ans);
}
int main(void) {
  fscanf(in, "%d %d", &n, &m);
  fact[0] = 1;
  for (int i = 1; i < MAX; i++) fact[i] = (fact[i - 1] * i) % m;
  solve(n);
  return 0;
}
