description: Note that the memory limit in this problem is lower than in others.
  
  You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom.
  
  You also have a token that is initially placed in cell n. You will move the token up until it arrives at cell 1.
  
  Let the token be in cell x > 1 at some moment. One shift of the token can have either of the following kinds: 
  
    * Subtraction: you choose an integer y between 1 and x-1, inclusive, and move the token from cell x to cell x - y. 
    * Floored division: you choose an integer z between 2 and x, inclusive, and move the token from cell x to cell ⌊ x/z ⌋ (x divided by z rounded down). 
  
  
  
  Find the number of ways to move the token from cell n to cell 1 using one or more shifts, and print it modulo m. Note that if there are several ways to move the token from one cell to another in one shift, all these ways are considered distinct (check example explanation for a better understanding).
  
  Input
  
  The only line contains two integers n and m (2 ≤ n ≤ 4 ⋅ 10^6; 10^8 < m < 10^9; m is a prime number) — the length of the strip and the modulo.
  
  Output
  
  Print the number of ways to move the token from cell n to cell 1, modulo m.
  
  Examples
  
  Input
  
  
  3 998244353
  
  
  Output
  
  
  5
  
  
  Input
  
  
  5 998244353
  
  
  Output
  
  
  25
  
  
  Input
  
  
  42 998244353
  
  
  Output
  
  
  793019428
  
  
  Input
  
  
  787788 100000007
  
  
  Output
  
  
  94810539
  
  Note
  
  In the first test, there are three ways to move the token from cell 3 to cell 1 in one shift: using subtraction of y = 2, or using division by z = 2 or z = 3.
  
  There are also two ways to move the token from cell 3 to cell 1 via cell 2: first subtract y = 1, and then either subtract y = 1 again or divide by z = 2.
  
  Therefore, there are five ways in total.
solution: import java.io.ByteArrayInputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.PrintWriter;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.Collections;
  import java.util.InputMismatchException;
  import java.util.List;
  
  public class Main {
  
  	private static final String NO = "No";
  	private static final String YES = "Yes";
  	InputStream is;
  	PrintWriter out;
  	String INPUT = "";
  
  	private static final long MOD = 1000000007;
  
  	void solve() {
  		int T = 1;// ni();
  
  		for (int i = 0; i < T; i++)
  			solve(i);
  	}
  
  	void solve(int nth) {
  		int n = ni(), m = ni();
  		int dp[] = new int[n + 1];
  		int suff[] = new int[n + 2];
  		dp[n] = 1;
  		suff[n] = 1;
  		suff[n + 1] = 0;
  
  		for (int i = n - 1; i >= 1; i--) {
  			dp[i] = suff[i + 1];
  			for (int b = 2; b <= n / i; b++) {
  //				tr(">", i, b, b * i, n + 1, b * i + b);
  				dp[i] += suff[b * i] - suff[Math.min(n + 1, b * i + b)];
  				if (dp[i] < 0)
  					dp[i] += m;
  				if (dp[i] > m)
  					dp[i] -= m;
  			}
  
  			suff[i] = suff[i + 1] + dp[i];
  			if (suff[i] > m)
  				suff[i] -= m;
  //			tr(i, dp, suff);
  		}
  		out.println(dp[1]);
  	}
  
  	// a^b
  	long power(long a, long b) {
  		long x = 1, y = a;
  		while (b > 0) {
  			if (b % 2 != 0) {
  				x = (x * y) % MOD;
  			}
  			y = (y * y) % MOD;
  			b /= 2;
  		}
  		return x % MOD;
  	}
  
  	private long gcd(long a, long b) {
  		while (a != 0) {
  			long tmp = b % a;
  			b = a;
  			a = tmp;
  		}
  		return b;
  	}
  
  	void run() throws Exception {
  		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
  		out = new PrintWriter(System.out);
  
  		long s = System.currentTimeMillis();
  		solve();
  		out.flush();
  		if (!INPUT.isEmpty())
  			tr(System.currentTimeMillis() - s + "ms");
  	}
  
  	public static void main(String[] args) throws Exception {
  		new Main().run();
  	}
  
  	private byte[] inbuf = new byte[1024];
  	public int lenbuf = 0, ptrbuf = 0;
  
  	private int readByte() {
  		if (lenbuf == -1)
  			throw new InputMismatchException();
  		if (ptrbuf >= lenbuf) {
  			ptrbuf = 0;
  			try {
  				lenbuf = is.read(inbuf);
  			} catch (IOException e) {
  				throw new InputMismatchException();
  			}
  			if (lenbuf <= 0)
  				return -1;
  		}
  		return inbuf[ptrbuf++];
  	}
  
  	private boolean isSpaceChar(int c) {
  		return !(c >= 33 && c <= 126);
  	}
  
  	private int skip() {
  		int b;
  		while ((b = readByte()) != -1 && isSpaceChar(b))
  			;
  		return b;
  	}
  
  	private double nd() {
  		return Double.parseDouble(ns());
  	}
  
  	private char nc() {
  		return (char) skip();
  	}
  
  	private char[] nc(int n) {
  		char[] ret = new char[n];
  		for (int i = 0; i < n; i++)
  			ret[i] = nc();
  		return ret;
  	}
  
  	private String ns() {
  		int b = skip();
  		StringBuilder sb = new StringBuilder();
  		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
  									// ')
  			sb.appendCodePoint(b);
  			b = readByte();
  		}
  		return sb.toString();
  	}
  
  	private char[] ns(int n) {
  		char[] buf = new char[n];
  		int b = skip(), p = 0;
  		while (p < n) {
  			if (!(isSpaceChar(b)))
  				buf[p++] = (char) b;
  			b = readByte();
  		}
  		return n == p ? buf : Arrays.copyOf(buf, p);
  	}
  
  	private char[][] nm(int n, int m) {
  		char[][] map = new char[n][];
  		for (int i = 0; i < n; i++)
  			map[i] = ns(m);
  		return map;
  	}
  
  	private int[] na(int n) {
  		int[] a = new int[n];
  		for (int i = 0; i < n; i++)
  			a[i] = ni();
  		return a;
  	}
  
  	private Integer[] na2(int n) {
  		Integer[] a = new Integer[n];
  		for (int i = 0; i < n; i++)
  			a[i] = ni();
  		return a;
  	}
  
  	private int[][] na(int n, int m) {
  		int[][] a = new int[n][];
  		for (int i = 0; i < n; i++)
  			a[i] = na(m);
  		return a;
  	}
  
  	private int ni() {
  		int num = 0, b;
  		boolean minus = false;
  		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
  			;
  		if (b == '-') {
  			minus = true;
  			b = readByte();
  		}
  
  		while (true) {
  			if (b >= '0' && b <= '9') {
  				num = num * 10 + (b - '0');
  			} else {
  				return minus ? -num : num;
  			}
  			b = readByte();
  		}
  	}
  
  	private Long[] nl2(int n) {
  		Long[] a = new Long[n];
  		for (int i = 0; i < n; i++)
  			a[i] = nl();
  		return a;
  	}
  
  	private long[] nl(int n) {
  		long[] a = new long[n];
  		for (int i = 0; i < n; i++)
  			a[i] = nl();
  		return a;
  	}
  
  	private long[][] nl(int n, int m) {
  		long[][] a = new long[n][];
  		for (int i = 0; i < n; i++)
  			a[i] = nl(m);
  		return a;
  	}
  
  	private long nl() {
  		long num = 0;
  		int b;
  		boolean minus = false;
  		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
  			;
  		if (b == '-') {
  			minus = true;
  			b = readByte();
  		}
  
  		while (true) {
  			if (b >= '0' && b <= '9') {
  				num = num * 10 + (b - '0');
  			} else {
  				return minus ? -num : num;
  			}
  			b = readByte();
  		}
  	}
  
  	static class SuffixArray {
  
  		// ALPHABET_SZ is the default alphabet size, this may need to be much
  		// larger if you're using the LCS method with multiple sentinels
  		int ALPHABET_SZ = 256, N;
  		int[] T, lcp, sa, sa2, rank, tmp, c;
  
  		public SuffixArray(String str) {
  			this(toIntArray(str));
  		}
  
  		private static int[] toIntArray(String s) {
  			int[] text = new int[s.length()];
  			for (int i = 0; i < s.length(); i++)
  				text[i] = s.charAt(i);
  			return text;
  		}
  
  		// Designated constructor
  		public SuffixArray(int[] text) {
  			T = text;
  			N = text.length;
  			sa = new int[N];
  			sa2 = new int[N];
  			rank = new int[N];
  			c = new int[Math.max(ALPHABET_SZ, N)];
  			construct();
  			kasai();
  		}
  
  		private void construct() {
  			int i, p, r;
  			for (i = 0; i < N; ++i)
  				c[rank[i] = T[i]]++;
  			for (i = 1; i < ALPHABET_SZ; ++i)
  				c[i] += c[i - 1];
  			for (i = N - 1; i >= 0; --i)
  				sa[--c[T[i]]] = i;
  			for (p = 1; p < N; p <<= 1) {
  				for (r = 0, i = N - p; i < N; ++i)
  					sa2[r++] = i;
  				for (i = 0; i < N; ++i)
  					if (sa[i] >= p)
  						sa2[r++] = sa[i] - p;
  				Arrays.fill(c, 0, ALPHABET_SZ, 0);
  				for (i = 0; i < N; ++i)
  					c[rank[i]]++;
  				for (i = 1; i < ALPHABET_SZ; ++i)
  					c[i] += c[i - 1];
  				for (i = N - 1; i >= 0; --i)
  					sa[--c[rank[sa2[i]]]] = sa2[i];
  				for (sa2[sa[0]] = r = 0, i = 1; i < N; ++i) {
  					if (!(rank[sa[i - 1]] == rank[sa[i]] && sa[i - 1] + p < N && sa[i] + p < N
  							&& rank[sa[i - 1] + p] == rank[sa[i] + p]))
  						r++;
  					sa2[sa[i]] = r;
  				}
  				tmp = rank;
  				rank = sa2;
  				sa2 = tmp;
  				if (r == N - 1)
  					break;
  				ALPHABET_SZ = r + 1;
  			}
  		}
  
  		// Use Kasai algorithm to build LCP array
  		private void kasai() {
  			lcp = new int[N - 1];
  			int[] inv = new int[N];
  			for (int i = 0; i < N; i++)
  				inv[sa[i]] = i;
  			for (int i = 0, len = 0; i < N; i++) {
  				if (inv[i] > 0) {
  					int k = sa[inv[i] - 1];
  					while ((i + len < N) && (k + len < N) && T[i + len] == T[k + len])
  						len++;
  					lcp[inv[i] - 1] = len;
  					if (len > 0)
  						len--;
  				}
  			}
  		}
  	}
  
  	private static void tr(Object... o) {
  		System.out.println(Arrays.deepToString(o));
  	}
  
  }
  