#include <bits/stdc++.h>
using namespace std;
const int N = 4e6 + 10;
long long f[N];
int js, sp;
int sum[N];
int get(int x, int l) { return x / (x / l); }
long long getsum(int x) {
  long long res = 0;
  for (int l = 2, r; l <= x; l = r + 1) {
    r = get(x, l);
    res = (long long)res + f[(x / l)] * (r - l + 1) % js;
  }
  return res;
}
int main() {
  cin >> sp >> js;
  f[1] = 1;
  sum[1] = 1;
  for (int i = 2; i <= sp; i++) {
    f[i] = (long long)(sum[i - 1] + getsum(i)) % js;
    sum[i] = (long long)(sum[i - 1] + f[i]) % js;
  }
  cout << (long long)(f[sp] + js) % js << endl;
  return 0;
}
