#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
long long MOD = 1000000007;
struct mi {
  long long v;
  explicit operator long long() const { return v; }
  mi() { v = 0; }
  mi(long long _v) {
    v = (-MOD < _v && _v < MOD) ? _v : _v % MOD;
    if (v < 0) v += MOD;
  }
  friend bool operator==(const mi &a, const mi &b) { return a.v == b.v; }
  friend bool operator!=(const mi &a, const mi &b) { return !(a == b); }
  friend bool operator<(const mi &a, const mi &b) { return a.v < b.v; }
  mi &operator+=(const mi &m) {
    if ((v += m.v) >= MOD) v -= MOD;
    return *this;
  }
  mi &operator-=(const mi &m) {
    if ((v -= m.v) < 0) v += MOD;
    return *this;
  }
  mi &operator*=(const mi &m) {
    v = v * m.v % MOD;
    return *this;
  }
  mi &operator/=(const mi &m) { return (*this) *= inv(m); }
  friend mi pow(mi a, long long p) {
    mi ans = 1;
    assert(p >= 0);
    for (; p; p /= 2, a *= a)
      if (p & 1) ans *= a;
    return ans;
  }
  friend mi inv(const mi &a) {
    assert(a.v != 0);
    return pow(a, MOD - 2);
  }
  mi operator-() const { return mi(-v); }
  mi &operator++() { return *this += 1; }
  mi &operator--() { return *this -= 1; }
  mi operator++(int) {
    mi temp;
    temp.v = v++;
    return temp;
  }
  mi operator--(int) {
    mi temp;
    temp.v = v--;
    return temp;
  }
  friend mi operator+(mi a, const mi &b) { return a += b; }
  friend mi operator-(mi a, const mi &b) { return a -= b; }
  friend mi operator*(mi a, const mi &b) { return a *= b; }
  friend mi operator/(mi a, const mi &b) { return a /= b; }
  friend ostream &operator<<(ostream &os, const mi &m) {
    os << m.v;
    return os;
  }
  friend istream &operator>>(istream &is, mi &m) {
    long long x;
    is >> x;
    m.v = x;
    return is;
  }
};
void solve() {
  long long n;
  cin >> n;
  long long m;
  cin >> m;
  MOD = m;
  vector<mi> dp(n + 1, 0);
  vector<mi> suffix(n + 2, 0);
  dp[n] = 1;
  suffix[n] = 1;
  mi sum = 0;
  for (long long i = (n)-1; i >= 1; i--) {
    sum = sum + dp[i + 1];
    dp[i] = sum;
    for (long long j = 2; j < (n + 1); j++) {
      if (i * j > n)
        break;
      else {
        mi sf = suffix[i * j] - suffix[min(i * j + j, n + 1)];
        dp[i] = dp[i] + sf;
      }
    }
    suffix[i] = suffix[i + 1] + dp[i];
  }
  cout << dp[1] << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  solve();
}
