This version of the problem differs from the next one only in the constraint on n.

Note that the memory limit in this problem is lower than in others.

You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom.

You also have a token that is initially placed in cell n. You will move the token up until it arrives at cell 1.

Let the token be in cell x > 1 at some moment. One shift of the token can have either of the following kinds: 

  * Subtraction: you choose an integer y between 1 and x-1, inclusive, and move the token from cell x to cell x - y. 
  * Floored division: you choose an integer z between 2 and x, inclusive, and move the token from cell x to cell ⌊ x/z ⌋ (x divided by z rounded down). 



Find the number of ways to move the token from cell n to cell 1 using one or more shifts, and print it modulo m. Note that if there are several ways to move the token from one cell to another in one shift, all these ways are considered distinct (check example explanation for a better understanding).

Input

The only line contains two integers n and m (2 ≤ n ≤ 2 ⋅ 10^5; 10^8 < m < 10^9; m is a prime number) — the length of the strip and the modulo.

Output

Print the number of ways to move the token from cell n to cell 1, modulo m.

Examples

Input


3 998244353


Output


5


Input


5 998244353


Output


25


Input


42 998244353


Output


793019428

Note

In the first test, there are three ways to move the token from cell 3 to cell 1 in one shift: using subtraction of y = 2, or using division by z = 2 or z = 3.

There are also two ways to move the token from cell 3 to cell 1 via cell 2: first subtract y = 1, and then either subtract y = 1 again or divide by z = 2.

Therefore, there are five ways in total.

Difficulty: MEDIUM_HARD

Solutions:
from io import BytesIO, IOBase
import sys
import math
import os
import heapq
from collections import defaultdict, deque
from math import ceil
from bisect import bisect_left, bisect_left
from time import perf_counter
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def mint():
	return map(int, input().split())

def mfloat():
	return map(float, input().split())

def intin():
	return int(input())

def solve():
	(n, mod) = map(int, input().split())
	dp = [0] * (n + 1)
	dp[-1] = 1
	current = 1
	suffix_sum = [0] * (n + 1)
	suffix_sum[-1] = 1
	for i in range(n - 1, 0, -1):
		dp[i] = suffix_sum[i + 1]
		for j in range(2, n + 1):
			if i * j > n:
				break
			dp[i] += suffix_sum[i * j] - (suffix_sum[i * j + j] if i * j + j <= n else 0)
			dp[i] %= mod
		suffix_sum[i] = (suffix_sum[i + 1] + dp[i]) % mod
	print(dp[1] % mod)

def main():
	t = 1
	for _ in range(t):
		solve()
start_time = perf_counter()
main()
print(perf_counter() - start_time, file=sys.stderr)


(n, m) = map(int, input().split())
sumL = [0] * (n + 2)
L = [0] * (n + 1)
(L[-1], sumL[-2]) = (1, 1)
for i in range(n - 1, 0, -1):
	L[i] = sumL[i + 1]
	j = 2
	while i * j <= n:
		L[i] += sumL[i * j] - sumL[min(n, (i + 1) * j - 1) + 1]
		j += 1
	L[i] = L[i] % m
	sumL[i] = (sumL[i + 1] + L[i]) % m
print(L[1])


for u in range(1):
	(n, m) = map(int, input().split())
	dp = [0 for i in range(n + 1)]
	dp[1] = 1
	p = [0] * (n + 1)
	cache = [[] for i in range(n + 1)]
	a = 0
	b = 1
	for i in range(2, n + 1):
		for j in cache[i]:
			a = (a - dp[p[j]] + m) % m
			p[j] += 1
			a = (a + dp[p[j]]) % m
		a = (a + dp[1]) % m
		dp[i] = (a + b) % m
		b = (b + dp[i]) % m
		p[i] = 1
		j = 2
		while i * j <= n:
			cache[i * j].append(i)
			j += 1
	print(dp[n])


(n, m) = map(int, input().split())
dp = [0 for i in range(n + 3)]
dp2 = [0 for i in range(n + 3)]
dp[n] = 1
dp2[n] = 1
for i in range(n - 1, 0, -1):
	dp[i] = dp2[i + 1] % m
	mul = 2
	while i * mul <= n:
		dp[i] = (dp[i] % m + dp2[i * mul] % m - dp2[min((i + 1) * mul, n + 1)] % m) % m
		mul += 1
	dp2[i] = (dp[i] % m + dp2[i + 1] % m) % m
print(dp[1] % m)


(n, m) = map(int, input().split())
c = [0] * n + [1] + [0] * n
for i in range(n - 1, 0, -1):
	c[i] = 2 * c[i + 1] % m
	for j in range(2, n // i + 1):
		c[i] = (c[i] + c[i * j] - c[(i + 1) * j]) % m
print((c[1] - c[2]) % m)


from sys import *
input = stdin.readline
import random
from bisect import *
import math
from collections import *
import operator
from heapq import *
from itertools import *
inf = 10 ** 18
mod = 10 ** 9 + 7
(n, m) = map(int, input().split())
dp = [0] * (n + 5)
suf = [0] * (n + 5)
dp[n] = 1
suf[n] = 1
for i in range(n - 1, 0, -1):
	dp[i] = (dp[i] + suf[i + 1]) % m
	suf[i] = suf[i + 1]
	j = 2
	while j * i <= n:
		l = j * i
		r = min(j * i + j - 1, n)
		dp[i] = (dp[i] + suf[l] - suf[r + 1]) % m
		j += 1
	suf[i] = (suf[i + 1] + dp[i]) % m
print(dp[1] % m)


from sys import stdin, gettrace
if gettrace():

	def inputi():
		return input()
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def main():
	(n, m) = map(int, input().split())
	nways = [0, 1, 2] + [0] * (n - 1)
	divisors = [[] for _ in range(n + 1)]
	for i in range(2, n + 1):
		for j in range(i, n + 1, i):
			divisors[j].append(i)
	for i in range(3, n + 1):
		nways[i] = nways[i - 1] * 2 % m
		for d in divisors[i]:
			nways[i] = (nways[i] + nways[i // d] - nways[(i - 1) // d]) % m
	print(nways[n])
main()


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
mod = m
dp = [0] * (n + 3)
dp[n] = 1
sdp = [0] * (n + 3)
sdp[n] = 1
for x in range(n - 1, 0, -1):
	dp[x] += sdp[x + 1]
	dp[x] %= mod
	z = 2
	while x * z <= n:
		l = x * z
		r = (x + 1) * z - 1
		if r > n:
			r = n
		dp[x] += sdp[l] - sdp[r + 1]
		dp[x] %= mod
		z += 1
	sdp[x] = sdp[x + 1] + dp[x]
	sdp[x] %= mod
print(dp[1] % mod)


(N, MOD) = map(int, input().split())
DP = [0] * N
DP[0] = 1
Cum = [0] * (N + 1)
Cum[1] = 1
for i1 in range(1, N):
	i2 = N - i1
	Value = Cum[i1]
	for j in range(2, N + 1):
		if i2 * j > N:
			break
		Value += Cum[N - i2 * j + 1] - Cum[max(0, N - i2 * j - j + 1)]
		Value %= MOD
	Cum[i1 + 1] += Cum[i1] + Value
	Cum[i1 + 1] %= MOD
	DP[i1] = Value
print(DP[-1])


import sys, os, io
import math
from collections import defaultdict
from io import BytesIO, IOBase
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, m) = li()
dif = [0] * (n + 10)
dp = [0] * (n + 1)
dp[1] = 1
suf = 0
for i in range(1, n + 1):
	dp[i] += suf
	dif[i] += dif[i - 1]
	dp[i] += dif[i]
	suf += dp[i]
	dp[i] %= m
	suf %= m
	dif[i] %= m
	for j in range(2, n + 1):
		if i * j > n:
			break
		low = i * j
		high = (i + 1) * j - 1
		dif[low] += dp[i]
		dif[min(high, n) + 1] -= dp[i]
print(dp[-1])


primes = []
for p in range(2, 6000):
	is_prime = True
	for p2 in primes:
		if p2 * p2 > p:
			break
		if p % p2 == 0:
			is_prime = False
			break
	if is_prime:
		primes.append(p)

def factor(n):
	d = {}
	for p in primes:
		if p * p > n:
			break
		if n % p == 0:
			c = 0
			while n % p == 0:
				n = n // p
				c += 1
			d[p] = c
	if n > 1:
		d[n] = 1
	return d

def factors(n):
	d = factor(n)
	answer = [1]
	for p in d:
		a2 = []
		for x in answer:
			for i in range(d[p] + 1):
				a2.append(x * p ** i)
		answer = a2
	return answer

def process(n, m):
	f_dict = {0: 0, 1: 1, 2: 2}
	for i in range(3, n + 1):
		f_dict[i] = 2 * f_dict[i - 1]
		for x in factors(i):
			if 2 <= x <= i:
				f_dict[i] += f_dict[i // x] - f_dict[(i - 1) // x]
				f_dict[i] = f_dict[i] % m
		f_dict[i] = f_dict[i] % m
	return f_dict[n]
(n, m) = [int(x) for x in input().split()]
print(process(n, m))


import os
import sys
import math
from io import BytesIO, IOBase
import io
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
from collections import Counter
import threading
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: math.gcd(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree1:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
MOD = 10 ** 9 + 7

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
mod = 10 ** 9 + 7
omod = 998244353
prime = [True for i in range(11)]
prime[0] = prime[1] = False

def SieveOfEratosthenes(n=10):
	p = 2
	c = 0
	while p <= n:
		if prime[p] == True:
			c += 1
			for i in range(p, n + 1, p):
				prime[i] = False
		p += 1

class DSU:

	def __init__(self, R, C):
		self.par = range(R * C + 1)
		self.rnk = [0] * (R * C + 1)
		self.sz = [1] * (R * C + 1)

	def find(self, x):
		if self.par[x] != x:
			self.par[x] = self.find(self.par[x])
		return self.par[x]

	def union(self, x, y):
		(xr, yr) = (self.find(x), self.find(y))
		if xr == yr:
			return
		if self.rnk[xr] < self.rnk[yr]:
			(xr, yr) = (yr, xr)
		if self.rnk[xr] == self.rnk[yr]:
			self.rnk[xr] += 1
		self.par[yr] = xr
		self.sz[xr] += self.sz[yr]

	def size(self, x):
		return self.sz[self.find(x)]

	def top(self):
		return self.size(len(self.sz) - 1) - 1

class LazySegTree:

	def __init__(self, _op, _e, _mapping, _composition, _id, v):

		def set(p, x):
			assert 0 <= p < _n
			p += _size
			for i in range(_log, 0, -1):
				_push(p >> i)
			_d[p] = x
			for i in range(1, _log + 1):
				_update(p >> i)

		def get(p):
			assert 0 <= p < _n
			p += _size
			for i in range(_log, 0, -1):
				_push(p >> i)
			return _d[p]

		def prod(l, r):
			assert 0 <= l <= r <= _n
			if l == r:
				return _e
			l += _size
			r += _size
			for i in range(_log, 0, -1):
				if l >> i << i != l:
					_push(l >> i)
				if r >> i << i != r:
					_push(r >> i)
			sml = _e
			smr = _e
			while l < r:
				if l & 1:
					sml = _op(sml, _d[l])
					l += 1
				if r & 1:
					r -= 1
					smr = _op(_d[r], smr)
				l >>= 1
				r >>= 1
			return _op(sml, smr)

		def apply(l, r, f):
			assert 0 <= l <= r <= _n
			if l == r:
				return
			l += _size
			r += _size
			for i in range(_log, 0, -1):
				if l >> i << i != l:
					_push(l >> i)
				if r >> i << i != r:
					_push(r - 1 >> i)
			l2 = l
			r2 = r
			while l < r:
				if l & 1:
					_all_apply(l, f)
					l += 1
				if r & 1:
					r -= 1
					_all_apply(r, f)
				l >>= 1
				r >>= 1
			l = l2
			r = r2
			for i in range(1, _log + 1):
				if l >> i << i != l:
					_update(l >> i)
				if r >> i << i != r:
					_update(r - 1 >> i)

		def _update(k):
			_d[k] = _op(_d[2 * k], _d[2 * k + 1])

		def _all_apply(k, f):
			_d[k] = _mapping(f, _d[k])
			if k < _size:
				_lz[k] = _composition(f, _lz[k])

		def _push(k):
			_all_apply(2 * k, _lz[k])
			_all_apply(2 * k + 1, _lz[k])
			_lz[k] = _id
		_n = len(v)
		_log = _n.bit_length()
		_size = 1 << _log
		_d = [_e] * (2 * _size)
		_lz = [_id] * _size
		for i in range(_n):
			_d[_size + i] = v[i]
		for i in range(_size - 1, 0, -1):
			_update(i)
		self.set = set
		self.get = get
		self.prod = prod
		self.apply = apply
MIL = 1 << 20

def makeNode(total, count):
	return total * MIL + count

def getTotal(node):
	return math.floor(node / MIL)

def getCount(node):
	return node - getTotal(node) * MIL
nodeIdentity = makeNode(0.0, 0.0)

def nodeOp(node1, node2):
	return node1 + node2
	return makeNode(getTotal(node1) + getTotal(node2), getCount(node1) + getCount(node2))
identityMapping = -1

def mapping(tag, node):
	if tag == identityMapping:
		return node
	count = getCount(node)
	return makeNode(tag * count, count)

def composition(mapping1, mapping2):
	return mapping1 if mapping1 != identityMapping else mapping2

def memodict(f):

	class memodict(dict):

		def __missing__(self, key):
			ret = self[key] = f(key)
			return ret
	return memodict().__getitem__

def pollard_rho(n):
	if n & 1 == 0:
		return 2
	if n % 3 == 0:
		return 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			prev = p
			p = p * p % n
			if p == 1:
				return math.gcd(prev - 1, n)
			if p == n - 1:
				break
		else:
			for i in range(2, n):
				(x, y) = (i, (i * i + 1) % n)
				f = math.gcd(abs(x - y), n)
				while f == 1:
					(x, y) = ((x * x + 1) % n, (y * y + 1) % n)
					y = (y * y + 1) % n
					f = math.gcd(abs(x - y), n)
				if f != n:
					return f
	return n

@memodict
def prime_factors(n):
	if n <= 1:
		return Counter()
	f = pollard_rho(n)
	return Counter([n]) if f == n else prime_factors(f) + prime_factors(n // f)

def distinct_factors(n):
	factors = [1]
	for (p, exp) in prime_factors(n).items():
		factors += [p ** i * factor for factor in factors for i in range(1, exp + 1)]
	return factors

def all_factors(n):
	(small, large) = ([], [])
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small.append(i)
			large.append(n // i)
	if small[-1] == large[-1]:
		large.pop()
	large.reverse()
	small.extend(large)
	return small

def binarySearch(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = n
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] > key:
			res = mid
			right = mid - 1
		else:
			left = mid + 1
	return res

def binarySearch1(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = -1
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] > key:
			right = mid - 1
		else:
			res = mid
			left = mid + 1
	return res
t = 1
for _ in range(t):
	(n, m) = map(int, input().split())
	dp = [0] * (n + 1)
	dp[1] = 1
	dp[2] = 2
	for i in range(3, n + 1):
		dp[i] = 2 * dp[i - 1] + dp[1]
		for f in all_factors(i):
			if f == 1 or f == i:
				continue
			dp[i] += dp[i // f] - dp[i // f - 1]
		dp[i] %= m
	print(dp[-1])


import sys
input = sys.stdin.readline

def ri():
	return [int(i) for i in input().split()]

def rs():
	return input().split()[0]

def main():
	t = 1
	for _ in range(t):
		(n, m) = ri()
		ans = [0] * (n + 1)
		sum = [0] * (n + 2)
		ans[n] = 1
		sum[n] = 1
		for x in range(n - 1, 0, -1):
			extra = sum[x + 1]
			for d in range(2, n // x + 1):
				from_ = x * d
				to_ = min(x * d + d - 1, n)
				extra = (extra + m + sum[from_] - sum[to_ + 1]) % m
			ans[x] = extra
			sum[x] = (sum[x + 1] + ans[x]) % m
		print(ans[1] % m)
main()


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
dp = [0] * (n + 2)
dp[n] = 1
for i in range(n - 1, 0, -1):
	dpi = dp[i + 1]
	j = 2
	while i * j < n + 2:
		dpi += dp[i * j] - dp[min(n + 1, (i + 1) * j)]
		dpi %= m
		j += 1
	dp[i] = dpi + dp[i + 1]
	dp[i] %= m
ans = (dp[1] - dp[2]) % m
print(ans)


from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from math import ceil, floor, log, gcd, sqrt
from collections import Counter, deque
from heapq import heappush, heappop, heapify

def re():
	return stdin.readline().rstrip()

def ints():
	return map(int, stdin.readline().split())

def test(tc):
	for _ in range(tc):
		solve()
mod = 1000000007
nl = '\n'

class Dsu:

	def __init__(self, n):
		self.parent = list(range(n))
		self.rank = [1] * n

	def find(self, x):
		while x != self.parent[x]:
			self.parent[x] = self.parent[self.parent[x]]
			x = self.parent[x]
		return x

	def union(self, x, y):
		(px, py) = (self.find(x), self.find(y))
		if px == py:
			return 0
		if self.rank[py] > self.rank[px]:
			(px, py) = (py, px)
		self.parent[py] = px
		self.rank[px] += self.rank[py]
		return 1

	def get_size(self, x):
		return self.rank[self.find(x)]

class SegTree:

	def __init__(self, n, array):
		self.n = n
		self.tree = [0] * (2 * n)
		for i in range(n, 2 * n):
			self.tree[i] = array[i - n]
		for i in range(n - 1, -1, -1):
			self.tree[i] = self.tree[2 * i] + self.tree[2 * i + 1]

	def update(self, i, val):
		self.tree[i] = val
		while i:
			self.tree[i] = self.tree[i * 2] + self.tree[i * 2 + 1]
			i //= 2

	def query(self):
		pass

	def top(self):
		return self.tree[0]

def solve():
	(n, m) = ints()
	dp = [0] * (n + 1)
	dp[n] = 1
	suf = [0] * (n + 2)
	suf[n] = 1
	for i in range(n - 1, 0, -1):
		dp[i] = suf[i + 1] % m
		for mul in range(2, n + 1):
			lo = i * mul
			hi = (i + 1) * mul - 1
			if lo > n:
				break
			dp[i] = (dp[i] + suf[lo] - suf[min(n, hi) + 1]) % m
		suf[i] = (suf[i + 1] + dp[i]) % m
	print(dp[1] % m)
	return
test(1)


(n, m) = map(int, input().split())
dp = [0] * (n + 2)
s = [0] * (n + 2)
dp[n] = 1
s[n] = 1
for i in range(n - 1, 0, -1):
	dp[i] = s[i + 1]
	for j in range(2, n // i + 1):
		h = min(n + 1, (i + 1) * j)
		dp[i] = (dp[i] + s[i * j] - s[h]) % m
	s[i] = (s[i + 1] + dp[i]) % m
print(dp[1])


(n, M) = map(int, input().split())
if n == 1:
	print(1)
	exit(0)
dp = [1] * (n + 1)
accu = [0] * (n + 1)
accu[1] = 1
accu[2] = 2
for j in range(4, n + 1, 2):
	dp[j] += dp[2]
for i in range(3, n + 1):
	dp[i] += accu[i - 1]
	for j in range(2 * i, n + 1, i):
		dp[j] += dp[i]
		dp[j] = dp[j] % M
	accu[i] = (accu[i - 1] + dp[i]) % M
print(accu[n])


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
from bisect import bisect_left as lower_bound, bisect_right as upper_bound

def so():
	return int(input())

def st():
	return input()

def mj():
	return map(int, input().strip().split(' '))

def msj():
	return map(str, input().strip().split(' '))

def le():
	return list(map(int, input().split()))

def lebe():
	return list(map(int, input()))

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()

def joro(L):
	return ''.join(map(str, L))

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def npr(n, r):
	return factorial(n) // factorial(n - r) if n >= r else 0

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r)) if n >= r else 0

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = -1
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = mid
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	li = []
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, len(prime)):
		if prime[p]:
			li.append(p)
	return li

def primefactors(n):
	factors = []
	while n % 2 == 0:
		factors.append(2)
		n //= 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			factors.append(i)
			n //= i
	if n > 2:
		factors.append(n)
	return factors

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def tr(n):
	return n * (n + 1) // 2

def fb(k, L):
	if k == L[k]:
		return k
	if L[k] == fb(L[k], L):
		return L[k]

def usa(a, b, Y, Z):
	a = fb(a, Y)
	b = fb(b, Y)
	if a != b:
		if Z[a] < Z[b]:
			(a, b) = (b, a)
		Y[b] = a
		Z[a] += Z[b]

def iu():
	import sys
	input = sys.stdin.buffer.readline
	import math as my
	(p, q) = mj()
	if p == 1:
		print(1)
		return
	L = []
	P = []
	for i in range(p + 1):
		L.append(1)
		P.append(0)
	P[1] = 1
	P[2] = 2
	j = 4
	while j < 1 + p:
		L[j] = L[2] + L[j]
		j = 2 + j
	i = 3
	while i < 1 + p:
		L[i] = P[i - 1] + L[i]
		L[i] %= q
		j = i * 2
		while j < 1 + p:
			L[j] = L[i] + L[j]
			L[j] %= q
			j += i
		P[i] = (P[i - 1] + L[i]) % q
		i += 1
	print(P[p])

def main():
	for i in range(1):
		iu()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
inputt = sys.stdin.readline
printt = sys.stdout.write
import math
import functools
from collections import deque
import heapq
from queue import PriorityQueue

def get():
	return inputt().split()

def getint():
	return int(inputt())

def getints():
	return map(int, inputt().split())
(n, m) = getints()
a = [1 for _ in range(n + 1)]
a[2] = 0
for x in range(2, n + 1):
	a[x] += 2 * a[x - 1]
	a[x] %= m
	delta = a[x] - a[x - 1]
	for y in range(2, n // x + 1):
		a[x * y] += delta
		a[x * y] %= m
	a[x - 2] = 0
print(a[n])


(n, M) = map(int, input().split(' '))
D = [[] for _ in range(n + 1)]
for d in range(2, n + 1):
	for dst in range(2 * d, n + 1, d):
		D[dst].append(d)
F = [None] * (n + 1)
F[1] = 1
F[2] = 2
for x in range(3, n + 1):
	F[x] = (2 * F[x - 1] + F[x // (x - 1)]) % M
	S = 0
	for d in D[x]:
		if 2 <= d <= x - 2:
			S += F[x // d] - F[(x - 1) // d]
	F[x] = (F[x] + S) % M
print(F[n] % M)


import os, sys
from io import BytesIO, IOBase
from math import log2, ceil, sqrt, gcd
from _collections import deque
import heapq as hp
from bisect import bisect_left, bisect_right
from math import cos, sin
from itertools import permutations
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7
(n, m) = map(int, input().split())
dp = [0] * (n + 1)
a = [0] * (n + 1)
dp[n] = 1
a[n] = 1
for i in range(n - 1, 0, -1):
	dp[i] = a[i + 1]
	z = 2
	while i * z <= n:
		dp[i] += a[i * z]
		if z * (i + 1) <= n:
			dp[i] -= a[z * (i + 1)]
		z += 1
		dp[i] %= m
	dp[i] %= m
	a[i] = a[i + 1] + dp[i]
	a[i] %= m
print(dp[1])


import os
import sys
import math
import collections
import functools
import itertools
import heapq
import bisect
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcde'
MOD = 10 ** 9 + 7
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def INT():
	return int(input())

def STR():
	return input()

def INTS():
	return tuple(map(int, input().split()))

def ARRINT():
	return [int(i) for i in input().split()]

def ARRSTR():
	return [i for i in input().split()]
(n, MOD) = INTS()
dp = [0] * (n + 2)
dp[n] = 1
for i in range(n - 1, 0, -1):
	tmp = dp[i + 1]
	j = 2
	while i * j < n + 2:
		tmp += dp[i * j] - dp[min(n + 1, (i + 1) * j)]
		tmp %= MOD
		j += 1
	dp[i] = tmp + dp[i + 1]
	dp[i] %= MOD
print((dp[1] - dp[2]) % MOD)


from sys import stdin
input = stdin.readline

def add(x, y):
	return (x % mod + y % mod) % mod

def sub(x, y):
	return (x - y + mod) % mod

def answer():
	dp = [0] * (n + 1)
	prefix = [0] * (n + 2)
	dp[n] = 1
	for i in range(n, 0, -1):
		dp[i] = add(dp[i], prefix[i + 1])
		j = 2
		while i * j <= n:
			dp[i] = add(dp[i], prefix[i * j])
			if j * i + j <= n:
				dp[i] = sub(dp[i], prefix[j * i + j])
			j += 1
		prefix[i] = add(prefix[i + 1], dp[i])
	return dp[1]
for T in range(1):
	(n, mod) = map(int, input().split())
	print(answer())


(n, mod) = map(int, input().split())
if n == 1:
	print(1)
	exit()
fact = [{} for i in range(n + 1)]
for i in range(1, n + 1):
	for j in range(i, n + 1, i):
		fact[j][i] = 1
ans = [0] * n
ans[0] = 1
ans[1] = 2
for i in range(2, n):
	ans[i] = 2 * ans[i - 1] % mod
	for j in fact[i + 1]:
		if j == i + 1:
			continue
		if j == 1:
			ans[i] = (ans[i] + ans[j - 1]) % mod
			continue
		ans[i] = (ans[i] + (ans[j - 1] - ans[j - 2])) % mod
print(ans[-1] % mod)


(n, m) = map(int, input().split())
dp = [0 for i in range(n + 1)]
dp[1] = 1
dp[2] = 2
for i in range(2, n + 1):
	if i > 2:
		dp[i] = (dp[i] + dp[i - 1] + dp[i - 1] + 1) % m
	for j in range(i + i, n + 1, i):
		dp[j] = (dp[j] + dp[i] - dp[i - 1]) % m
print((dp[n] + m) % m)


(n, M) = map(int, input().split())
fact = [{} for i in range(n + 1)]
for i in range(1, n + 1):
	for j in range(i, n + 1, i):
		fact[j][i] = 1
dp = [0] * (n + 1)
accu = [0] * (n + 1)
dp[1] = 1
dp[2] = 2
extra = 0
for i in range(3, n + 1):
	dp[i] = 2 * dp[i - 1] % M
	for ele in fact[i]:
		if ele == i:
			continue
		dp[i] += dp[ele] - dp[ele - 1]
		dp[i] = dp[i] % M
print(dp[n])


from sys import path_hooks, stdin, stdout
import sys

def mapinput():
	return map(int, stdin.readline().split())
(n, m) = mapinput()
factors = [[] for i in range(n + 1)]
for i in range(1, n + 1):
	for j in range(i + i, n + 1, i):
		factors[j].append(i)
for test in range(1):

	def solve():
		memo = {0: 0, 1: 1, 2: 2, 3: 5}
		for i in range(4, n + 1):
			ans = memo[i - 1] * 2
			for j in factors[i]:
				ans += memo[j] - memo[j - 1]
			ans %= m
			memo[i] = ans
		return memo[n]
	print(solve())


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for i in range(1):
	(n, m) = map(int, input().split())
	dp = [0] * (n + 1)
	s = [0] * (n + 2)
	dp[n] = 1
	s[n] = 1
	for i in range(n - 1, 0, -1):
		dp[i] = s[i + 1]
		j = 2
		while i * j <= n:
			if (i + 1) * j - 1 <= n:
				dp[i] += (s[j * i] - s[(i + 1) * j]) % m
			else:
				dp[i] += s[j * i]
			dp[i] %= m
			j += 1
		s[i] += (s[i + 1] + dp[i]) % m
	print(dp[1] % m)


def solve(n, mod):
	a = [0] * (n - 1) + [1]
	b = [0] * (n - 1) + [1]
	for i in range(n - 2, -1, -1):
		(a[i], m) = (b[i + 1], 2)
		s = (i + 1) * m - 1
		while s < n:
			e = min((i + 2) * m - 2, n - 1)
			a[i] = (a[i] + b[s] - b[e] + a[e]) % mod
			m += 1
			s = (i + 1) * m - 1
		b[i] = (b[i + 1] + a[i]) % mod
	return a[0]
(n, m) = map(int, input().split())
print(solve(n, m))