#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<i64> f(n + 1), suf(n + 5);
  f[n] = suf[n] = 1;
  for (int i = n - 1; i >= 1; i--) {
    f[i] = (f[i] + suf[i + 1]) % m;
    for (int j = 2; i * j <= n; j++) {
      f[i] = (f[i] + suf[i * j] - suf[min(n + 1, i * j + j)] + m) % m;
    }
    suf[i] = (suf[i + 1] + f[i]) % m;
  }
  cout << f[1] << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
  return 0;
}
