#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long N = 2e5 + 5;
const double pi = acos(-1.0);
long long addM(long long a, long long b) { return (a + b) % MOD; }
long long multM(long long a, long long b) { return (a * b) % MOD; }
long long binpow(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}
long long ModInverse(long long n) { return binpow(n, MOD - 2); }
vector<long long> findFact() {
  vector<long long> fact(N);
  fact[0] = 1;
  for (long long i = 1; i <= N; i++) {
    fact[i] = multM(i, fact[i - 1]);
  }
  return fact;
}
long long ncr(long long n, long long r) {
  vector<long long> fact = findFact();
  return ((fact[n] * ModInverse(fact[n - r])) % MOD * ModInverse(fact[r])) %
         MOD;
}
vector<bool> findPrime() {
  vector<bool> is_prime(N + 1, true);
  is_prime[0] = false;
  is_prime[1] = false;
  for (long long i = 2; i <= N; i++) {
    if (is_prime[i] && i * i <= N) {
      for (long long j = i * i; j <= N; j += i) is_prime[j] = false;
    }
  }
  return is_prime;
}
vector<bool> segmentedSieveNoPreGen(long long L, long long R) {
  vector<bool> isPrime(R - L + 1, true);
  long long lim = sqrt(R);
  for (long long i = 2; i <= lim; ++i)
    for (long long j = max(i * i, (L + i - 1) / i * i); j <= R; j += i)
      isPrime[j - L] = false;
  if (L == 1) isPrime[0] = false;
  return isPrime;
}
long long dp[N];
long long carry[N];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long tt;
  tt = 1;
  while (tt--) {
    long long n, m;
    cin >> n >> m;
    dp[1] = 0;
    carry[1] = 0;
    long long sum = 0;
    for (long long j = 2; j <= n; j++) {
      carry[j] += 1;
      carry[j * (2)] -= 1;
    }
    for (long long i = 2; i <= n; i++) {
      carry[i] = (carry[i] + carry[i - 1]) % m;
      dp[i] = sum + 1;
      dp[i] = (dp[i] + carry[i]) % m;
      sum = (sum + dp[i]) % m;
      for (long long j = 2; j * i <= n; j++) {
        carry[j * i] = (carry[j * i] + dp[i]) % m;
        carry[j * (i + 1)] = (carry[j * (i + 1)] - dp[i] + m) % m;
      }
    }
    cout << dp[n] << '\n';
  }
  return 0;
}
