#include <iostream>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int dp[n + 1];
int suff[n + 2];
dp[n] = 1;
suff[n] = 1;
suff[n + 1] = 0;
for (int i = n - 1; i >= 1; i--) {
dp[i] = suff[i + 1];
for (int b = 2; b <= n / i; b++) {
dp[i] += suff[b * i] - suff[min(n + 1, b * i + b)];
while (dp[i] < 0)
dp[i] += m;
dp[i] %= m;
}
suff[i] = suff[i + 1] + dp[i];
suff[i] %= m;
}
cout << dp[1] << endl;
}