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())

inp = lambda dtype: [dtype(x) for x in input().split()]
ceil1 = lambda a, b: (a + b - 1) // b
add = lambda a, b: (a + b) % mod
mult = lambda a, b: (a * b) % mod

n, mod = inp(int)
mem, prefix = [0] * (n + 1), [0] * (n + 2)
mem[1] = su = 1

for i in range(2, n + 1):
    j = 2
    while j * (i - 1) <= n:
        prefix[j * (i - 1)] = add(prefix[j * (i - 1)], mem[i - 1])
        prefix[min(j * i, n + 1)] = add(prefix[min(j * i, n + 1)], mult(-1, mem[i - 1]))
        j += 1

    prefix[i] = add(prefix[i - 1], prefix[i])
    mem[i] = add(prefix[i], su)
    su = add(su, mem[i])

print(mem[-1])

from math import sqrt

inp = lambda dtype: [dtype(x) for x in input().split()]
ceil1 = lambda a, b: (a + b - 1) // b
add = lambda a, b: (a + b) % mod
mult = lambda a, b: (a * b) % mod

n, mod = inp(int)
mem, su = [0] * (n + 1), 1
mem[1] = 1

for i in range(2, n + 1):
    sq, cur = int(sqrt(i)) + 1, su

    for f in range(2, sq):
        cur = (cur + mem[i // f]) % mod

    be = i
    for j in range(1, i // sq + 1):
        nxt = i // (j + 1)
        cur = (cur + (be - nxt) * mem[j]) % mod
        be = nxt

    su = (su + cur) % mod
    mem[i] = cur
print(mem[-1])

from math import sqrt

inp = lambda dtype: [dtype(x) for x in input().split()]
ceil1 = lambda a, b: (a + b - 1) // b
add = lambda a, b: (a + b) % mod
mult = lambda a, b: (a * b) % mod

n, mod = inp(int)
mem, su = [0] * (n + 1), 1
mem[1] = 1

for i in range(2, n + 1):
    sq, cur = int(sqrt(i)) + 1, su

    for f in range(2, sq):
        cur = add(cur, mem[i // f])

    be = i
    for j in range(1, i // sq + 1):
        nxt = i // (j + 1)
        cur = add(cur, (be - nxt) * mem[j])
        be = nxt

    su = add(su, cur)
    mem[i] = cur
print(mem[-1])

from math import sqrt

inp = lambda dtype: [dtype(x) for x in input().split()]
ceil1 = lambda a, b: (a + b - 1) // b
add = lambda a, b: (a + b) % mod
mult = lambda a, b: (a * b) % mod

n, mod = inp(int)
mem, su = [0, 1], 1

for i in range(2, n + 1):
    sq, cur = int(sqrt(i)) + 1, su

    for f in range(2, sq):
        cur = add(cur, mem[i // f])

    be = i
    for j in range(1, i // sq + 1):
        nxt = i // (j + 1)
        cur = add(cur, (be - nxt) * mem[j])
        be = nxt

    su = add(su, cur)
    mem.append(cur)
print(mem[-1])

from math import sqrt

inp = lambda dtype: [dtype(x) for x in input().split()]
ceil1 = lambda a, b: (a + b - 1) // b
add = lambda a, b: (a + b) % mod
mult = lambda a, b: (a * b) % mod

n, mod = inp(int)
mem, su = [0, 1], 1

for i in range(2, n + 1):
    sq, cur = int(sqrt(i)) + 1, su

    for f in range(2, sq):
        cur = add(cur, mem[i // f])

    be = i
    for j in range(1, i // sq + 1):
        nxt = i // (j + 1)
        cur = add(cur, mult(be - nxt, mem[j]))
        be = nxt

    su = add(su, cur)
    mem.append(cur)
print(mem[-1])

inp = lambda dtype: [dtype(x) for x in input().split()]
ceil1 = lambda a, b: (a + b - 1) // b
add = lambda a, b: (a + b) % mod
mult = lambda a, b: (a * b) % mod

n, mod = inp(int)
mem, su = [0, 1], 1

for i in range(2, n + 1):
    sq ,cur= int(i ** .5) + 1,su

    for f in range(2, sq):
        cur = add(cur, mem[i // f])

    be = i
    for j in range(1, i // sq + 1):
        nxt = i // (j + 1)
        cur = add(cur, mult(be - nxt, mem[j]))
        be = nxt

    su = add(su, cur)
    mem.append(cur)
print(mem[-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]
    dp[i] = dp[i]%M

    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(dp)
#print(accu)

print(accu[n])

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(dp)
#print(accu)

print(accu[n])

n, M = map(int,input().split())

dp = [0]*(n+1)
accu = [0]*(n+1)

dp[1] = 1
dp[2] = 1
accu[1] = 1
accu[2] = 2
extra = 0

for i in range(3,n+1):
    dp[i] = accu[i-1]
    for j in range(1,int(i**0.5)+1):
        if i%j==0:
            dp[i] += dp[j]
            dp[i] = dp[i] % M
            if j>1 and j*j<i:
                dp[i] += dp[i//j]
                dp[i] = dp[i] % M
    accu[i] = (accu[i-1] + dp[i])%M

#print(dp)

print(accu[n])

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)

print(dp[n])

# This code is contributed by Siddharth

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

# inverse modulo power pow(a,-1,mod) - it only works on py 3.8 ( *not in pypy )

# ==========================================> Code Starts Here <=====================================================================

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)

import sys
inputt=sys.stdin.readline
printt=sys.stdout.write

import math
import functools  # functools.reduce
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])

import sys
from io import BytesIO, IOBase
import os

################################ <fast I/O> ###########################################
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, **kwargs):
        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)

#############################################<I/O Region >##############################################

def inp():
    return sys.stdin.readline().strip()

def map_inp(v_type):
    return map(v_type, inp().split())

def list_inp(v_type):
    return list(map_inp(v_type))

######################################## Solution ####################################

n, m = map_inp(int)
dp = [0 for col in range(n + 1)]
add_q = [0 for item in range(n + 2)]
dp[n] = 1
add_q[n] = 1
for i in range(n - 1, 0, -1):
    dp[i] += add_q[i + 1] % m
    z = 2
    for temp in range(i * z, n + 1, i):
        left = i * z
        right = min(i * z + z - 1, n)
        dp[i] += add_q[left] - add_q[right + 1]
        dp[i] %= m
        z += 1
    add_q[i] += dp[i] + add_q[i + 1]
    add_q[i] %= m
print(dp[1])

import sys
import io, os
import math
from heapq import *
gcd = math.gcd
sqrt = math.sqrt
def ceil(a,b):
    a=-a
    k=a//b
    k=-k
    return k
# arr=list(map(int, input().split()))
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
def strinp(testcases):
    k = 5
    if (testcases == -1 or testcases == 1):
        k = 1
    f = str(input())
    f = f[2:len(f) - k]
    return f
def sieve(n):
    prime = [0 for i in range(n + 1)]
    p = 2
    if (prime[p] == 0):
            for i in range(p * p, n + 1, p):
                prime[i] = p
    p+=1
    while (p * p <= n):
        if (prime[p] == 0):
            for i in range(p * p, n + 1, p):
                prime[i] = p
        p += 2
    return prime
def cleanarr(arr):
    n = len(arr)
    #  put comment if arr already sorted
    c = [[arr[0], 1]]
    k = 0
    for i in range(n - 1):
        if (arr[i] != arr[i + 1]):
            c.append([arr[i + 1], 1])
            k += 1
        else:
            c[k][1] += 1
    return c
def factors(l,k):
    if(l==[]):
        return([])
    if(k==len(l)-1):
        ans = [0]*(l[k][1]+1)
        for i in range(l[k][1]+1):
            ans[i]=l[k][0]**i
        return ans
    p=factors(l,k+1)
    og=len(p)
    for i in range(1,l[k][1]+1):
        n=l[k][0]
        for j in range(og):
            p.append(p[j]*(n**i))
    return p
def pfactors(n,l):
    if(l[n]==0):
        return([])
    curr=n
    ans=[]
    while(True):
        f=l[curr]
        if(f==0):
            ans.append(curr)
            break
        ans.append(f)
        curr=curr//f
    ans.sort()
    ans=cleanarr(ans)
    return ans
def main():
    arr=list(map(int, input().split()))
    n=arr[0]
    m=arr[1]
    dp=[0]*(n+2)
    dp[1]=1
    dp[2]=2
    dp[3]=5
    if(n<4):
        print(dp[n])
        sys.exit()
    p=sieve(n)
    for i in range(4,n+1):
        dp[i]=(2*dp[i-1]+1)%m
        f=pfactors(i,p)
        g=factors(f,0)
        for h in range(1,len(g)-1):
            j=g[h]
            f=i//j
            dp[i]+=(dp[i//j]-dp[(i-1)//j])
            dp[i]=dp[i]%m
    print(dp[n])
main()

import sys
import io, os
import math
from heapq import *
gcd = math.gcd
sqrt = math.sqrt
def ceil(a,b):
    a=-a
    k=a//b
    k=-k
    return k
# arr=list(map(int, input().split()))
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
def strinp(testcases):
    k = 5
    if (testcases == -1 or testcases == 1):
        k = 1
    f = str(input())
    f = f[2:len(f) - k]
    return f
def main():
    arr=list(map(int, input().split()))
    n=arr[0]
    m=arr[1]
    dp=[0]*(n+2)
    dp[1]=1
    dp[2]=2
    dp[3]=5
    if(n<4):
        print(dp[n])
        sys.exit()
    for i in range(4,n+1):
        dp[i]=(2*dp[i-1]+1)%m
        p=int(i**(0.5))
        for j in range(2,p+1):
            if(i%j==0):
                if(j*j==i):
                    dp[i]+=(dp[i//j]-dp[(i-1)//j])
                    dp[i]=dp[i]%m
                else:
                    f=i//j
                    dp[i]+=(dp[i//j]-dp[(i-1)//j])
                    dp[i] += (dp[i // f] - dp[(i - 1) // f])
                    dp[i]=dp[i]%m
    print(dp[n])
main()

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")
#######################################
# #######
  #     #
  #######
  #   #
  #    #
  #      #   Rahul Kaushik.2.0 #

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)

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])

if __name__ == "__main__":
    main()

import math

n, m = map(int, input().split())

dp = [0, 1]
s = [0, 1]

for i in range(2,n+1):
    y = i**0.5
    k = math.ceil(y)

    res = s[-1]
    #print("res",res)

    l = i // (1 + 1) + 1
    r = i // 1
    # print("l, r",l,r)
    res += (r - l + 1) * dp[1]

    for j in range(2,k+int(k*k==i)):
        l = i//(j+1)+1
        r = i//j
        #print("l, r",l,r)
        res += (r-l+1)*dp[j]
        if i//j > y:
            res += dp[r]

    s.append((s[-1]+res)%m)
    dp.append(res%m)

print(dp[n])

# Legends Always Come Up with Solution
# Author: Manvir Singh

import os
import sys
from io import BytesIO, IOBase

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

# FASTIO REGION

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")

if __name__ == "__main__":
    main()

import sys
from array import array

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)
        # ans[n] = 1
        # sum = [0] * (n + 2)  # ans[x] + ... + ans[n]
        sum = array('L', range(n + 2))  # ans[x] + ... + ans[n]
        sum[n] = 1
        sum[n+1] = 0

        last = -1
        for x in range(n - 1, 0, -1):
            extra = sum[x + 1]  # jump by subtraction

            # jump by division
            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

            last = extra
            sum[x] = (sum[x + 1] + last) % m
        # print(ans)
        print(last % m)

main()

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[x] + ... + ans[n]
        ans[n] = 1
        sum[n] = 1
        for x in range(n - 1, 0, -1):
            extra = sum[x + 1]  # jump by subtraction

            # jump by division
            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)
        print(ans[1] % m)

main()

def naiveSolve():

    return

def solve():

    return

import __pypy__
int_add = __pypy__.intop.int_add
int_sub = __pypy__.intop.int_sub
int_mul = __pypy__.intop.int_mul
def make_mod_mul(mod = 10**9 + 7):
    fmod_inv = 1.0 / mod
    def mod_mul(a, b, c=0):
        res = int_sub(
            int_add(int_mul(a, b), c),
            int_mul(mod, int(fmod_inv * a * b + fmod_inv * c)),
        )
        if res >= mod:
            return res - mod
        elif res < 0:
            return res + mod
        else:
            return res
    return mod_mul

def main():

    n,MOD=readIntArr()

    mod_mul=make_mod_mul(MOD)

    dp=[0]*(n+5)
    dp[1]=1
    prefixSum=1
    for i in range(2,n+1):
        dp[i]+=prefixSum
        # print('i:{} pfx:{}'.format(i,prefixSum))
        # sqRtI=pow(i,0.5)
        z=2
        visitedDivisors=set()
        while z*z<=i:
            dp[i]+=dp[i//z]
            dp[i]%=MOD
            visitedDivisors.add(i//z)
            # print('i:{} z:{} i//z:{}'.format(i,z,i//z))
            z+=1
        c=1
        # while c*c<i:
        while c*c<i and c not in visitedDivisors:
            zLeft=floor(i/(c+1)+1)
            zRight=floor(i/c)
            cnts=zRight-zLeft+1
            toAdd=mod_mul(dp[c],cnts)
            dp[i]+=toAdd
            dp[i]%=MOD
            # print('i:{} c:{} zLeft:{} zRight:{} cnts:{}'.format(i,c,zLeft,zRight,cnts))
            c+=1
        prefixSum+=dp[i]
        prefixSum%=MOD
    ans=dp[n]
    # print(dp)
    print(ans)

    return

import sys
input=sys.stdin.buffer.readline #FOR READING PURE INTEGER INPUTS (space separation ok)
# input=lambda: sys.stdin.readline().rstrip("\r\n") #FOR READING STRING/TEXT INPUTS.

def oneLineArrayPrint(arr):
    print(' '.join([str(x) for x in arr]))
def multiLineArrayPrint(arr):
    print('\n'.join([str(x) for x in arr]))
def multiLineArrayOfArraysPrint(arr):
    print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
    return [int(x) for x in input().split()]
# def readFloatArr():
#     return [float(x) for x in input().split()]

def makeArr(defaultValFactory,dimensionArr): # eg. makeArr(lambda:0,[n,m])
    dv=defaultValFactory;da=dimensionArr
    if len(da)==1:return [dv() for _ in range(da[0])]
    else:return [makeArr(dv,da[1:]) for _ in range(da[0])]

def queryInteractive(x):
    print('{}'.format(x))
    sys.stdout.flush()
    return int(input())

def answerInteractive(ans):
    print('! {}'.format(ans))
    sys.stdout.flush()

inf=float('inf')
# MOD=10**9+7
MOD=998244353

from math import gcd,floor,ceil
# from math import floor,ceil # for Python2

for _abc in range(1):
    main()

from collections import defaultdict, Counter,deque
from math import sqrt, log10, log, floor, factorial,gcd
from bisect import bisect_left, bisect_right
from itertools import permutations,combinations
import sys, io, os
input = sys.stdin.readline
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
# sys.setrecursionlimit(10000)
inf = float('inf')
mod = 10 ** 9 + 7
def yn(a): print("YES" if a else "NO")
ceil = lambda a, b: (a + b - 1) // b
class LazySegmentTree:
    def __init__(self, data, default=0, func=max, mod=-1):
        """initialize the lazy segment tree with data"""
        self.m = mod

        self._default = default
        self._func = func

        self._len = len(data)
        self._size = _size = 1 << (self._len - 1).bit_length()
        self._lazy = [0] * (2 * _size)

        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 __len__(self):
        return self._len

    def _push(self, idx):
        """push query on idx to its children"""
        # Let the children know of the queries
        q, self._lazy[idx] = self._lazy[idx], 0

        self._lazy[2 * idx] = (self._lazy[2 * idx] + q) % self.m
        self._lazy[2 * idx + 1] = (self._lazy[2 * idx + 1] + q) % self.m
        self.data[2 * idx] = (self.data[2 * idx] + q) % self.m
        self.data[2 * idx + 1] = (self.data[2 * idx + 1] + q) % self.m

    def _update(self, idx):
        """updates the node idx to know of all queries applied to it via its ancestors"""
        for i in reversed(range(1, idx.bit_length())):
            self._push(idx >> i)

    def _build(self, idx):
        """make the changes to idx be known to its ancestors"""
        idx >>= 1
        while idx:
            self.data[idx] = (self._func(self.data[2 * idx], self.data[2 * idx + 1]) + self._lazy[idx]) % self.m
            idx >>= 1

    def add(self, start, stop, value):
        """lazily add value to [start, stop)"""
        start = start_copy = start + self._size
        stop = stop_copy = stop + self._size
        while start < stop:
            if start & 1:
                self._lazy[start] = (self._lazy[start] + value) % self.m
                self.data[start] = (self.data[start] + value) % self.m
                start += 1
            if stop & 1:
                stop -= 1
                self._lazy[stop] = (self._lazy[stop] + value) % self.m
                self.data[stop] = (self.data[stop] + value) % self.m
            start >>= 1
            stop >>= 1

        # Tell all nodes above of the updated area of the updates
        self._build(start_copy)
        self._build(stop_copy - 1)

    def query(self, start, stop, default=0):
        """func of data[start, stop)"""
        start += self._size
        stop += self._size

        # Apply all the lazily stored queries
        self._update(start)
        self._update(stop - 1)

        res = 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 __getitem__(self, idx):
        return self.query(idx, idx + 1)

    def __repr__(self):
        return "LazySegmentTree({0})".format(self.data)
t=1
for i in range(t):
    n,m=[int(i) for i in input().split()]
    arr=LazySegmentTree([0 for i in range(n+1)],mod=m)
    arr.add(1,2,1)
    for i in range(1,n):
        arr.add(i+1,n+1,arr[i])
        for j in range(2,n//i+1):
            arr.add(i*j,min(j*(i+1),n+1),arr[i])
    # print([arr[i] for i in range(n+1)])
    print(arr[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())

from __future__ import division, print_function
import math
import sys
import os
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")

def print(*args, **kwargs):
	"""Prints the values to a stream, or to sys.stdout by default."""
	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")

def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input().strip()
    return(list(s[:len(s)]))
def invr():
    return(map(int,input().split()))
def Divisors(n) :
    i = 1
    fac=[]
    while i <= int(math.sqrt(n)):

        if (n % i == 0) :
            if (n // i == i) :
                fac.append(i)
            else :
                fac.append(i)
                fac.append(n//i)
        i = i + 1
    return fac
n,maxn=invr()
dp=[0 for i in range(n+1)]
dp[1]=1
dp[2]=2
sm=3
for i in range(3,n+1):
    dp[i]=(2*dp[i-1])%maxn
    fac=Divisors(i)
    fac.sort()
    for j in fac:
        if j==i:continue
        dp[i]+=dp[j]-dp[j-1]
        dp[i]=dp[i]%maxn
print(dp[n]%maxn)
# print(dp)

# ------------------- fast io --------------------
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")

# ------------------- fast io --------------------
from math import ceil

def prod(a, mod=10 ** 9 + 7):
    ans = 1
    for each in a:
        ans = (ans * each) % mod
    return ans

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

def lcm(a, b): return a * b // gcd(a, b)

def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y

from collections import Counter

def gcd(x, y):
    """greatest common divisor of x and y"""
    while y:
        x, y = y, x % y
    return x

def memodict(f):
    """memoization decorator for a function taking a single argument"""

    class memodict(dict):
        def __missing__(self, key):
            ret = self[key] = f(key)
            return ret

    return memodict().__getitem__

def pollard_rho(n):
    """returns a random factor of 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 gcd(prev - 1, n)
            if p == n - 1:
                break
        else:
            for i in range(2, n):
                x, y = i, (i * i + 1) % n
                f = gcd(abs(x - y), n)
                while f == 1:
                    x, y = (x * x + 1) % n, (y * y + 1) % n
                    y = (y * y + 1) % n
                    f = gcd(abs(x - y), n)
                if f != n:
                    return f
    return n

@memodict
def prime_factors(n):
    """returns a Counter of the prime factorization of 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):
    """returns a list of all distinct factors of 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):
    """returns a sorted list of all distinct factors of 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

for _ in range(int(input()) if not True else 1):
    #n = int(input())
    n, m = map(int, input().split())
    # a, b = map(int, input().split())
    # c, d = map(int, input().split())
    # a = list(map(int, input().split()))
    # b = list(map(int, input().split()))
    # s = input()
    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

n,m=map(int,input().split())

S=[i for i in range(n+1)]

for i in range(2,n+1):
    if S[i]==i:
        for j in range(i,n+1,i):
            if S[j]==j:
                S[j]=i

def fact(x):
    NOW={1}
    while x!=1:
        NOW|={n*S[x] for n in NOW}
        x//=S[x]

    return NOW

DP=[0]*(n+5)

DP[1]=1
DP[2]=2
DP[3]=5
#DP[4]=12
#DP[5]=25

for i in range(4,n+1):
    SU=DP[i-1]*2+1

    for f in fact(i):
        if f==1 or f==i:
            continue
        SU+=DP[i//f]-DP[(i-1)//f]

    DP[i]=SU%m

print(DP[n])

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, mod = map(int, input().split())

dp = [0] * (n + 1)
dp[n] = 1
sdp = [0] * (n + 2)
sdp[n] = 1
for i in range(n - 1, 0, -1):
    cur = 2
    while True:
        if i * cur > n:
            break

        start = i * cur
        end = min(n, (i + 1) * cur - 1)

        dp[i] += sdp[start] - sdp[end + 1]
        dp[i] %= mod

        cur += 1

    dp[i] += sdp[i + 1]
    dp[i] %= mod

    sdp[i] = dp[i] + sdp[i + 1]
    sdp[i] %= mod

print(dp[1])

import math,sys;input=sys.stdin.readline;S=lambda:input().rstrip();I=lambda:int(S());M=lambda:map(int,S().split());L=lambda:list(M());mod1=1000000007;mod2=998244353

n,m=M()
p=[0]*(n+2);p[n]=1
for i in range(n-1,0,-1):
    cur=p[i+1]
    for j in range(2,n//i +1):
        l=j*i;r=min(j*i+j-1,n)
        cur=(cur+(p[l]-p[r+1])%m)%m
    p[i]=(p[i+1]+cur)%m
print((p[1]-p[2])%m)

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, 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)

#Code by Sounak, IIESTS
#------------------------------warmup----------------------------

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

#sys.setrecursionlimit(300000)
#threading.stack_size(10**8)

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")

#-------------------game starts now-----------------------------------------------------
#mod = 9223372036854775807
class SegmentTree:
    def __init__(self, data, default=0, func=lambda a, b: math.gcd(a,b)):
        """initialize the segment tree with data"""
        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):
        """initialize the segment tree with data"""
        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)  # To make sure already calculated n^-1
        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
#pp=[0]*10
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):
                #pp[i]=1
                prime[i] = False
        p += 1
#-----------------------------------DSU--------------------------------------------------
class DSU:
    def __init__(self, R, C):
        #R * C is the source, and isn't a grid square
        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):
        # Size of component at ephemeral "source" node at index R*C,
        # minus 1 to not count the source itself in the size
        return self.size(len(self.sz) - 1) - 1
#---------------------------------Lazy Segment Tree--------------------------------------
# https://github.com/atcoder/ac-library/blob/master/atcoder/lazysegtree.hpp
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):
    # Pack a pair into a float
    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
    # Equivalent to the following:
    return makeNode(
        getTotal(node1) + getTotal(node2), getCount(node1) + getCount(node2)
    )

identityMapping = -1

def mapping(tag, node):
    if tag == identityMapping:
        return node
    # If assigned, new total is the number assigned times count
    count = getCount(node)
    return makeNode(tag * count, count)

def composition(mapping1, mapping2):
    # If assigned multiple times, take first non-identity assignment
    return mapping1 if mapping1 != identityMapping else mapping2
#---------------------------------Pollard rho--------------------------------------------
def memodict(f):
    """memoization decorator for a function taking a single argument"""
    class memodict(dict):
        def __missing__(self, key):
            ret = self[key] = f(key)
            return ret

    return memodict().__getitem__

def pollard_rho(n):
    """returns a random factor of 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):
    """returns a Counter of the prime factorization of 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):
    """returns a list of all distinct factors of 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):
    """returns a sorted list of all distinct factors of 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

#---------------------------------Binary Search------------------------------------------
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
#---------------------------------running code------------------------------------------
t=1
#t=int(input())
for _ in range (t):
    #n=int(input())
    n,m=map(int,input().split())
    #a=list(map(int,input().split()))
    #b=list(map(int,input().split()))
    #s=input()
    #n=len(s)
    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])

n, M = map(int, input().split())
factors = [[] for _ in range(n+1)]
for d in range(2, n // 2+1):
    for q in range(2*d, n+1, d):
        factors[q].append(d)
ans = [0, 1]
d = [0, 0]
p = 1
for i in range(2, n+1):
    d.append((d[-1] + 1 + sum(ans[i//x] - ans[i//x-1] for x in factors[i])) % M)
    ans.append((p + d[-1]) % M)
    p = (p + ans[-1]) % M
print(ans[-1])

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  # min index where x is not less than num

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  # max index where x is not greater than num

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

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

def kadane(x):  # maximum sum contiguous subarray
    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):  # only odd factors left
        while n % i == 0:
            factors.append(i)
            n //= i
    if n > 2:  # incase of prime
        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()

# region fastio
# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py

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):
    """Prints the values to a stream, or to sys.stdout by default."""
    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")

# endregion

if __name__ == "__main__":
    #read()
    main()
    #dmain()

# Comment Read()

import sys
import collections

infile = sys.stdin.buffer
def gs()  : return infile.readline().rstrip()
def gi()  : return int(gs())
def gss() : return gs().split()
def gis() : return [int(x) for x in gss()]

MOD = 10 ** 9 + 7
INF = 10 ** 12
N = 10 ** 5

def main(infn="") :
    global infile
    infile = open(infn,"r") if infn else open(sys.argv[1],"r") if len(sys.argv) > 1 else sys.stdin
    ######################################################################
    n,m = gis()
    dp = [0 for _ in range(n+1)]
    dp[1] = 1
    h = [0 for _ in range(n+1)]
    cumul = 0
    prev = dp[1]

    for u in range(1, len(dp)):
        if u > 1:
            dp[u] += prev + dp[1]
            dp[u] %= m

            cumul += h[u]
            cumul %= m

            dp[u] += cumul
            dp[u] %= m

            prev += dp[u]
            prev %= m
        '''u = 7
        14 + 0, 14 + 1, 14 + 2
        7        7         8
        '''
        j = 2
        while( j * u < len(dp)):
            if j*u != 2:
                h[j*u] += dp[u]
                h[j*u] %= m
            if j*u + j< len(dp):
                h[j*u + j] -= dp[u]
                h[j*u + j] %= m
            j+=1
    print (dp[-1])

    ######################################################################
if __name__ == '__main__' :
    main()

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)

# ///////////////////////////////////////////////////////////////////////////
# //////////////////// PYTHON IS THE BEST ////////////////////////
# ///////////////////////////////////////////////////////////////////////////

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()))
# ///////////////////////////////////////////////////////////////////////////
# //////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
# ///////////////////////////////////////////////////////////////////////////
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])

# ------------------------template--------------------------#
import os
import sys
import math
import collections
import functools
import itertools

# from fractions import *
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-6

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()]

# -------------------------code---------------------------#

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)

##import random
##n = 10
##u = list(range(1, n + 1))
##random.shuffle(u)
##print(*u)
##while True:
##    x = int(input())
##    p = u[:x]
##    p.reverse()
##    u = p + u[x:]
##    print(*u)

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])

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)

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])
# print(dp,a)

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)

# template begins
#####################################
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

# region fastio

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())

#####################################
# template ends
# Use the recursion snippet if heavy recursion is needed (depth>1000)
# If constraints are tight, use 1d arrays instead of 2d, like g[i*m+j] instead of g[i][j]
def solve():
    n, mod = map(int, input().split())
    dp = [0]*(n+1)
    dp[-1] = 1
    # brute force
    # for i in range(n, 1, -1):
    #     for j in range(1, i):
    #         dp[j] = (dp[j] + dp[i]) % mod
    #     for j in range(2, i+1):
    #         dp[i//j] = (dp[i] + dp[i//j]) % mod
    # print(dp[1])
    """
    2^(n-2) ways by addition alone? yes
    """
    # for i in range(n-1, 0, -1):
    #     by_addition = pow(2, n-i-1, mod)
    # print("power =", pow(2, n-2, mod))
    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*i, n+1, i):
        #     dp[i] = (dp[i] + suffix_sum[j] -
        #              (suffix_sum[j+j] if j+j < n else 0))  # % mod
        #     break
        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)
    # print(suffix_sum)
    print(dp[1] % mod)

def main():
    t = 1
    # t = int(input())
    for _ in range(t):
        solve()

if __name__ == "__main__":
    start_time = perf_counter()
    main()
    print(perf_counter()-start_time, file=sys.stderr)

class BIT:
    def __init__(self,n:int):
        q = 1 << (n - 1).bit_length() + 1
        self.ceiling = q
        self.bittree = [0]*(q + 1)

    def updatebit(self, v:int, n:int):
        v = v * 2 - 1
        self.bittree[v] = n
        while v < self.ceiling:
            s = int(v)
            count = 0
            while not s & 1:
                s >>= 1
                count += 1
            v += 2 ** count
            self.bittree[v] += n

    def getIntervalSum(self,l:int,r:int):
        #[l,r]
        l = l * 2 - 2
        r = r * 2 - 1
        ret = 0
        while r > 0:
            ret += self.bittree[r]
            s = int(r)
            count = 0
            while not s & 1:
                s >>= 1
                count += 1
            r -= 2 ** count
        while l > 0:
            ret -= self.bittree[l]
            s = int(l)
            count = 0
            while not s & 1:
                s >>= 1
                count += 1
            l -= 2 ** count
        return ret

n, mod = map(int,input().split())

dp = [0 for _ in range(n + 1)]

bittree = BIT(n)

dp[n] = 1
bittree.updatebit(n,1)
sum = 1

for i in range(n-1,0,-1):
    for j in range(2,n+1):
        if i * j <= n:
            dp[i] = (dp[i] + bittree.getIntervalSum(i*j,min((i+1)*j - 1,n))) % mod
        else:
            break
    dp[i] = (dp[i] + sum) % mod
    bittree.updatebit(i,dp[i])
    sum = (sum + dp[i]) % mod
print(dp[1])

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])

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 sys,math
input=sys.stdin.readline
INF=int(1e9)

def find_all_divisors_of_a_number(x):
    result = []
    for i in range(2, int(math.sqrt(x)) + 1):
        if x % i == 0:
            result.append(i)
            if i * i != x:
                result.append(x // i)
    return result

def solve():
    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]+1
        data=find_all_divisors_of_a_number(i)
        for j in data:
            dp[i]+=dp[j]-dp[j-1]
        dp[i]%=m

    print(dp[n])

t=1

while t:
    t-=1
    solve()

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)

inp = lambda dtype: [dtype(x) for x in input().split()]
ceil1 = lambda a, b: (a + b - 1) // b
add = lambda a, b: (a + b) % mod
mult = lambda a, b: (a * b) % mod

n, mod = inp(int)
mem, su = [0, 1], 1

for i in range(2, n + 1):
    sq = int(i ** .5) + 1
    mem.append(su)

    for f in range(2, sq):
        mem[-1] = add(mem[-1], mem[i // f])

    be = i
    for j in range(1, i // sq + 1):
        nxt = i // (j + 1)
        mem[-1] = add(mem[-1], mult(be - nxt, mem[j]))
        be = nxt

    su = add(su, mem[-1])
print(mem[-1])

import os,sys
from random import randint
from io import BytesIO, IOBase

from collections import defaultdict,deque,Counter
from bisect import bisect_left,bisect_right
from heapq import heappush,heappop
from functools import lru_cache
from itertools import accumulate
import math

# Fast IO Region
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 _ in range(int(input())):
#     n = int(input())
#     a = list(map(int, input().split()))

# for _ in range(int(input())):
#     n = int(input())
#     a = list(map(int, input().split()))
#     b = sorted(a)
#     ans = 0
#     op = 0
#     while a != b:
#         if op == 0:
#             for i in range(0, n, 2):
#                 if i + 1 < n and a[i] > a[i + 1]:
#                     a[i], a[i + 1] = a[i + 1], a[i]
#         else:
#             for i in range(1, n, 2):
#                 if i + 1 < n and a[i] > a[i + 1]:
#                     a[i], a[i + 1] = a[i + 1], a[i]
#         op ^= 1
#         ans += 1
#     print(ans)

    # n//2+1 r n//2 s xxxxx ....
    # n//2+1 s n//2 r ..... xxxx
    # a=3 b=5 [1,7]
    # 1=4,b=4 [0,8]
    # [n//2-a,n//2+a]
    # a=5,b=4 [0,9]
    # a=3,b=6 [1,8]
    # a=2,b=7 [2,7]
    # a=1,b=8 [3,6]
    # a=0,b=9 [4,5]
    # [n//2-a,n//2+1+a]

# for _ in range(int(input())):
#     a, b = list(map(int, input().split()))
#     if a > b: a, b = b, a
#     n = a + b
#     if n % 2 == 0:
#         ans = []
#         for i in range(n // 2 - a, n // 2 + a + 1, 2):
#             ans.append(i)
#     else:
#         ans = []
#         for i in range(n // 2 - a, n // 2 + a + 2):
#             ans.append(i)
#     print(len(ans))
#     print(*ans)

# for _ in range(int(input())):
#     n = int(input())
#     a = [list(map(int, input().split()))[1:] for _ in range(n)]
#     need = [0] * n
#     for i in range(n):
#         needi = 0
#         cur = 0
#         for j in a[i]:
#             if cur <= j:
#                 needi += j - cur + 1
#                 cur = j + 1
#             cur += 1
#         need[i] = needi

#     id = [i for i in range(n)]
#     id.sort(key=lambda x:need[x])
#     cur = ans = need[id[0]]
#     cur += len(a[id[0]])
#     for i in range(1, n):
#         if cur < need[id[i]]:
#             ans += need[id[i]] - cur
#             cur = need[id[i]]
#         cur += len(a[id[i]])
#     print(ans)

# x -> x//z = y dp[y]+=dp[y*z] +...+ dp[y*z+z-1]

n, mod = list(map(int, input().split()))

dp = [0] * (n + 1)
sdp = [0] * (n + 2)
dp[n] = sdp[n] = 1
for i in range(n - 1, 0, -1):
    dp[i] = sdp[i + 1]
    for j in range(2, 10000000000):
        if i * j > n:
            break
        dp[i] += sdp[i * j] - sdp[min(n + 1, i * j + j)]
    dp[i] %= mod
    sdp[i] = (sdp[i + 1] + dp[i]) % mod
# print(dp)
print(dp[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):
        # add sum from i*j to i*(j+1) - 1
        # from cells divided by j
        h = min(n + 1, (i + 1) * j)
        dp[i] = (dp[i] + s[i * j] - s[h]) % m
        # print("  i=",i,"j=", j, "h=",h)
    s[i] = (s[i+1] + dp[i]) % m
    # print ("i=", i)
    # print("dp:", * dp)
    # print("s:", *s)
print(dp[1])

from sys import stdin
raw_input = lambda: stdin.readline().rstrip()
input = lambda: int(raw_input())
I=lambda: map(int, raw_input().split())
n,m = I()
lst = [0, 1]
suffix = [0, 1]
c = 1
for i in xrange(n-1, 0, -1):
	q = 0
	j = 2
	w = i*j
	while w<=n:
		q = (q+suffix[n-w+1]-suffix[max(0, n-w-j+1)])%m
		j += 1
		w = i*j
	q = (c+q)%m
	c = (q+c)%m
	lst.append(q)
	suffix.append(c)
print lst[n]
# print lst
# print suffix

from sys import stdin
from math import sqrt
# raw_input = input
# xrange = range
raw_input = lambda: stdin.readline().rstrip()
input = lambda: int(raw_input())
I=lambda: map(int, raw_input().split())
n,m = I()
dp = [0]*(n+1)
dp[1] = 1
s = 1
for x in xrange(2, n+1):
	w = 0
	q = int(sqrt(x))
	q1 = q+(0 if q**2==x else 1)
	q2 = q1-1
	for j in xrange(2, q1): #j<sqrt(x)
		w += dp[x//j]
	w = w%m
	for c in xrange(1, q+1):
		a1 = x//(c+1)
		a2 = x//c
		if a1>q2:
			w += dp[c]*(a2-a1)
		else:
			w += dp[c]*(a2-q2)
	dp[x] = (s + w)%m
	s = (s+dp[x])%m
print(dp[n])

from sys import stdin
from math import sqrt
# raw_input = input
# xrange = range
raw_input = lambda: stdin.readline().rstrip()
input = lambda: int(raw_input())
I=lambda: map(int, raw_input().split())
n,m = I()
dp = [0]*(n+1)
dp[1] = 1
s = 1
for x in xrange(2, n+1):
	w = 0
	q = int(sqrt(x))
	q1 = q+(0 if q**2==x else 1)
	q2 = q1-1
	for j in xrange(2, q1): #j<sqrt(x)
		w = w+dp[x//j]
	w = w%m
	for c in xrange(1, q+1):
		a1 = x//(c+1)
		a2 = x//c
		w = w+dp[c]*(a2-max(a1, q2))
	dp[x] = (s + w)%m
	s = (s+dp[x])%m
print(dp[n])

import sys
testing = len(sys.argv) == 4 and sys.argv[3] == "myTest"
interactive = False
if testing:
    cmd = sys.stdout
    from time import time
    start_time = int(round(time() * 1000))
    readAll = open(sys.argv[1], 'r').read
    sys.stdout = open(sys.argv[2], 'w')
else:
    readAll = sys.stdin.read

# ############ ---- I/O Functions ---- ############

class InputData:
    def __init__(self):
        self.lines = readAll().split('\n')
        self.n = len(self.lines)
        self.ii = -1
    def input(self):
        self.ii += 1
        assert self.ii < self.n
        return self.lines[self.ii]

flush = sys.stdout.flush
if interactive and not testing:
    input = sys.stdin.readline
else:
    inputData = InputData()
    input = inputData.input

def intin():
    return(int(input()))
def intlin():
    return(list(map(int,input().split())))
def chrin():
    return(list(input()))
def strin():
    return input()
def lout(l, sep="\n", toStr=True):
    print(sep.join(map(str, l) if toStr else l))
def dout(*args, **kargs):
    if not testing: return
    if args: print(args[0] if len(args)==1 else args)
    if kargs: print([(k,v) for k,v in kargs.items()])
def ask(q):
    sys.stdout.write(str(q)+'\n')
    flush()
    return intin()

# ############ ---- I/O Functions ---- ############

# from math import ceil
# from collections import defaultdict as ddict, Counter
# from heapq import *
# from Queue import Queue
# for i in xrange(1,42):
#     dout(i, 42/i, 42/(i+1))
def main():
    n,m = intlin()
    dp = [0]*(n+1)
    dp[1] = 1
    summ = 1
    for x in xrange(2,n+1):
        i = 1
        y = int(x**0.5)
        while i < y:
            dp[x] += (dp[i]*(x/i-x/(i+1)))
            i += 1
        dp[x] %= m
        k = x/i
        while k > 1:
            dp[x] += dp[x/k]
            k -= 1
        dp[x] = (dp[x]+summ)%m
        summ += dp[x]
    return dp[n]%m

anss = []
anss.append(main())
    # anss.append("YES" if main() else "NO")
lout(anss)

if testing:
    sys.stdout = cmd
    print(int(round(time() * 1000))  - start_time)

import sys
testing = len(sys.argv) == 4 and sys.argv[3] == "myTest"
interactive = False
if testing:
    cmd = sys.stdout
    from time import time
    start_time = int(round(time() * 1000))
    readAll = open(sys.argv[1], 'r').read
    sys.stdout = open(sys.argv[2], 'w')
else:
    readAll = sys.stdin.read

# ############ ---- I/O Functions ---- ############

class InputData:
    def __init__(self):
        self.lines = readAll().split('\n')
        self.n = len(self.lines)
        self.ii = -1
    def input(self):
        self.ii += 1
        assert self.ii < self.n
        return self.lines[self.ii]

flush = sys.stdout.flush
if interactive and not testing:
    input = sys.stdin.readline
else:
    inputData = InputData()
    input = inputData.input

def intin():
    return(int(input()))
def intlin():
    return(list(map(int,input().split())))
def chrin():
    return(list(input()))
def strin():
    return input()
def lout(l, sep="\n", toStr=True):
    print(sep.join(map(str, l) if toStr else l))
def dout(*args, **kargs):
    if not testing: return
    if args: print(args[0] if len(args)==1 else args)
    if kargs: print([(k,v) for k,v in kargs.items()])
def ask(q):
    sys.stdout.write(str(q)+'\n')
    flush()
    return intin()

# ############ ---- I/O Functions ---- ############

# from math import ceil
# from collections import defaultdict as ddict, Counter
# from heapq import *
# from Queue import Queue
# for i in xrange(1,42):
#     dout(i, 42/i, 42/(i+1))
def main():
    n,m = intlin()
    dp = [0]*(n+1)
    dp[1] = 1
    summ = 1
    for x in xrange(2,n+1):
        i = 1
        y = int(x**0.5)
        while i < y:
            dp[x] += (dp[i]*(x/i-x/(i+1)))
            i += 1
        k = x/i
        while k > 1:
            dp[x] += dp[x/k]
            k -= 1
        dp[x] = (dp[x]+summ)%m
        summ += dp[x]
    return dp[n]%m

anss = []
anss.append(main())
    # anss.append("YES" if main() else "NO")
lout(anss)

if testing:
    sys.stdout = cmd
    print(int(round(time() * 1000))  - start_time)

#!/usr/bin/env python
from __future__ import division, print_function

import os
import 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

class LazySegmentTree:
    def __init__(self, data, default=0, func=max, mod=-1):
        """initialize the lazy segment tree with data"""
        self.m = mod

        self._default = default
        self._func = func

        self._len = len(data)
        self._size = _size = 1 << (self._len - 1).bit_length()
        self._lazy = [0] * (2 * _size)

        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 __len__(self):
        return self._len

    def _push(self, idx):
        """push query on idx to its children"""
        # Let the children know of the queries
        q, self._lazy[idx] = self._lazy[idx], 0

        self._lazy[2 * idx] = (self._lazy[2 * idx] + q) % self.m
        self._lazy[2 * idx + 1] = (self._lazy[2 * idx + 1] + q) % self.m
        self.data[2 * idx] = (self.data[2 * idx] + q) % self.m
        self.data[2 * idx + 1] = (self.data[2 * idx + 1] + q) % self.m

    def _update(self, idx):
        """updates the node idx to know of all queries applied to it via its ancestors"""
        for i in reversed(range(1, idx.bit_length())):
            self._push(idx >> i)

    def _build(self, idx):
        """make the changes to idx be known to its ancestors"""
        idx >>= 1
        while idx:
            self.data[idx] = (self._func(self.data[2 * idx], self.data[2 * idx + 1]) + self._lazy[idx]) % self.m
            idx >>= 1

    def add(self, start, stop, value):
        """lazily add value to [start, stop)"""
        start = start_copy = start + self._size
        stop = stop_copy = stop + self._size
        while start < stop:
            if start & 1:
                self._lazy[start] = (self._lazy[start] + value) % self.m
                self.data[start] = (self.data[start] + value) % self.m
                start += 1
            if stop & 1:
                stop -= 1
                self._lazy[stop] = (self._lazy[stop] + value) % self.m
                self.data[stop] = (self.data[stop] + value) % self.m
            start >>= 1
            stop >>= 1

        # Tell all nodes above of the updated area of the updates
        self._build(start_copy)
        self._build(stop_copy - 1)

    def query(self, start, stop, default=0):
        """func of data[start, stop)"""
        start += self._size
        stop += self._size

        # Apply all the lazily stored queries
        self._update(start)
        self._update(stop - 1)

        res = 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 __getitem__(self, idx):
        return self.query(idx, idx + 1)

    def __repr__(self):
        return "LazySegmentTree({0})".format(self.data)

def main():
    n, m = map(int, input().split())

    sol = LazySegmentTree([0] * (n + 1), mod=m)
    sol.add(1, 2, 1)

    for i in range(1, n):
        sol.add(i + 1, n + 1, sol[i])
        for j in range(2, (n // i) + 1):
            sol.add(i * j, min(n + 1, (i + 1) * j), sol[i])

    print(sol[n])

# region fastio

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):
    """Prints the values to a stream, or to sys.stdout by default."""
    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")

# endregion

if __name__ == "__main__":
    main()

n, M = map(int,input().split())

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 j in range(1,int(i**0.5)+1):
        if i%j==0:
            dp[i] += dp[j] - dp[j-1]
            if j*j<i and j!=1:

               dp[i] += dp[i//j] - dp[i//j-1]

#print(dp)

print(dp[n])

# This code is contributed by Siddharth

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

# inverse modulo power pow(a,-1,mod) - it only works on py 3.8 ( *not in pypy )

# ==========================================> Code Starts Here <=====================================================================

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)

import sys
inputt=sys.stdin.readline
printt=sys.stdout.write

import math
import functools  # functools.reduce
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)]
sum = 1
for x in range(2, n+1):
    a[x] = sum
    y = math.floor(x**0.5)
    for d in range(1, y+1):
        a[x]+=(x//d-x//(d+1))*a[d]
    for z in range(2, x//(y+1)+1):
        a[x]+=a[x//z]
    a[x] %= m
    sum += a[x]
    sum %= m
print([a[i+1]-a[i] for i in range(len(a)-1)])

import sys
from io import BytesIO, IOBase
import os
import math
################################ <fast I/O> ###########################################
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, **kwargs):
        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)

#############################################<I/O Region >##############################################

def inp():
    return sys.stdin.readline().strip()

def map_inp(v_type):
    return map(v_type, inp().split())

def list_inp(v_type):
    return list(map_inp(v_type))

######################################## Solution ####################################

n, m = map_inp(int)
dp = [0 for col in range(n + 1)]
dp[1] = 1
add_q = 1
for i in range(2, n + 1):
    dp[i] += add_q % m
    temp = int(math.sqrt(i))
    for j in range(1, temp + 1):
        if 1 < j < temp:
            dp[i] += dp[i // j] % m
        dp[i] += (dp[j] * (abs((i // (j + 1)) - (i // j)))) % m
    dp[i] %= m
    add_q += dp[i]
print(dp[n])

from sys import stdin
from math import sqrt
# raw_input = input
# xrange = range
raw_input = lambda: stdin.readline().rstrip()
input = lambda: int(raw_input())
I=lambda: map(int, raw_input().split())
n,m = I()
dp = [0]*(n+1)
dp[1] = 1
s = 1
for x in xrange(2, n+1):
	w = 0
	q = int(sqrt(x))
	q1 = q+(0 if q**2==x else 1)
	q2 = q1-1
	for j in xrange(2, q1): #j<sqrt(x)
		w = (w+dp[x//j])%m
	for c in xrange(1, q+1):
		a1 = x//(c+1)
		a2 = x//c
		w = (w+(dp[c]*(a2-a1))%m)%m
	dp[x] = (s + w)%m
	s = (s+dp[x])%m
print(dp[n])

from sys import stdin
from math import sqrt
# raw_input = input
# xrange = range
raw_input = lambda: stdin.readline().rstrip()
input = lambda: int(raw_input())
I=lambda: map(int, raw_input().split())
n,m = I()
dp = [0.0]*(n+1)
dp[1] = 1.0
s = 1.0
for x in xrange(2, n+1):
	w = 0.0
	q = int(sqrt(x))
	q1 = q+(0 if q**2==x else 1)
	for j in xrange(2, q1): #j<sqrt(x)
		w = (w+dp[x//j])%m
	for c in xrange(1, q+1):
		a1 = x//(c+1)
		a2 = x//c
		if a2>a1 and a2>q1-1:
			w = (w+(dp[c]*(a2-max(a1, q1-1)))%m)%m
	dp[x] = (s + w)%m
	s = (s+dp[x])%m
print(dp[n])