#include <bits/stdc++.h>
using namespace std;
const int N = 4e6 + 10;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const int UP = 31500;
const double PI = acos(-1.0);
const double eps = -1e8;
int f[N], sum[N];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  int n, mod;
  cin >> n >> mod;
  f[n] = 1;
  sum[n + 1] = 0;
  sum[n] = 1;
  for (int i = n - 1; i >= 1; i--) {
    f[i] = sum[i + 1];
    for (int j = 2; (long long)i * j <= n; j++)
      f[i] = (f[i] + (sum[i * j] - sum[min((i + 1) * j, n + 1)])) % mod;
    f[i] = (f[i] + mod) % mod;
    sum[i] = (sum[i + 1] + f[i]) % mod;
  }
  cout << f[1] << '\n';
}
