#include <bits/stdc++.h>
using namespace std;
const long long mx = 4e6 + 9;
long long m;
long long dp[mx];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n >> m;
  long long tot = 1;
  dp[1] = 1;
  for (long long i = 2; i <= n; i++) {
    dp[i] = tot;
    long long suru = 2;
    while (suru <= i) {
      long long ses = i / suru;
      ses = i / ses;
      long long tot = ses - suru + 1;
      dp[i] += (tot * dp[i / suru]) % m;
      dp[i] %= m;
      suru = ses + 1;
    }
    tot += dp[i];
    tot %= m;
  }
  cout << dp[n] << '\n';
}
