#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
using namespace std;
double eps = 1e-12;
template <class T>
void swp(T& a, T& b) {
  T temp = a;
  a = b;
  b = temp;
}
long long ceil_div(long long a, long long b) {
  return a % b == 0 ? a / b : a / b + 1;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long modex(long long x, unsigned int y, long long p) {
  long long res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int binarySearch(int arr[], int l, int r, int x) {
  if (r >= l) {
    int mid = l + (r - l) / 2;
    if (arr[mid] == x) return mid;
    if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x);
    return binarySearch(arr, mid + 1, r, x);
  }
  return -1;
}
const long long MOD = 998244353;
const long long mod = 1e9 + 7;
void solve() {}
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> v(n + 2);
  v[n] = 1ll;
  for (long long i = n - 1; i > 0ll; --i) {
    v[i] = v[i + 1];
    for (long long j = 2ll; j < n + 1ll; j++) {
      if (j * i > n) break;
      v[i] = (v[i] + (v[j * i] - v[min(n, j * (i + 1ll) - 1ll) + 1ll])) % m;
    }
    v[i] = (v[i] + v[i + 1ll]) % m;
  }
  if (v[1] >= v[2]) {
    cout << v[1] - v[2];
  } else {
    cout << (m + v[1] - v[2]) % m;
  }
  return 0;
}
