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.util.*;
  import java.io.*;
  
  import static java.lang.Math.*;
  
  public class Main
  {
      static MyScanner scan;
      static PrintWriter pw;
      static long MOD = 1_000_000_007;
      static long INF = 2_000_000_000_000_000_000L;
      static long inf = 2_000_000_000;
      public static void main(String[] args) {
          new Thread(null, null, "_", 1 << 27) {
              public void run() {
                  try {
                      solve();
                  } catch (Exception e) {
                      e.printStackTrace();
                      System.exit(1);
                  }
              }
          }.start();
      }
  
  
      static void solve() throws java.lang.Exception {
          //initIo(true, "");
          initIo(false, "");
          StringBuilder sb = new StringBuilder();
  
          int n = ni(), mod = ni();
          long ways[] = new long[n+1];
          long sum = 0;
          ways[1] = 1;
          long pref[] = new long[n+1];
          for(int i=1;i<=n;i++) {
              pref[i] = (pref[i] + pref[i-1])%mod;
              ways[i] += pref[i];
              ways[i] += sum;
              ways[i] %= mod;
              for(int j=2;i*j<=n;j++) {
                  int l = i*j;
                  int r = (i+1)*j-1;
                  if(l<=r) {
                      pref[l] = (pref[l] + ways[i]) % mod;
                      if(r+1<=n) {
                          pref[r + 1] = (pref[r + 1] - ways[i] + mod) % mod;
                      }
                  }
              }
  
              sum = (sum + ways[i])%mod;
          }
  
          // pa("ways", ways);
          pl(ways[n]);
  
          pw.flush();
          pw.close();
      }
  
  
      static void assert_in_range(String varName, int n, int l, int r) {
          if (n >=l && n<=r) return;
          System.out.println(varName + " is not in range. Actual: "+n+" l : "+l+" r: "+r);
          System.exit(1);
      }
      static void assert_in_range(String varName, long n, long l, long r) {
          if (n>=l && n<=r) return;
          System.out.println(varName + " is not in range. Actual: "+n+" l : "+l+" r: "+r);
          System.exit(1);
      }
  
      static void initIo(boolean isFileIO, String suffix) throws IOException {
          scan = new MyScanner(isFileIO, suffix);
          if(isFileIO) {
              pw = new PrintWriter("/Users/dsds/Desktop/output"+suffix+".txt");
          }
          else {
              pw = new PrintWriter(System.out, true);
          }
      }
      static int ni() throws IOException
      {
          return scan.nextInt();
      }
      static long nl() throws IOException
      {
          return scan.nextLong();
      }
      static double nd() throws IOException
      {
          return scan.nextDouble();
      }
      static String ne() throws IOException
      {
          return scan.next();
      }
      static String nel() throws IOException
      {
          return scan.nextLine();
      }
      static void pl()
      {
          pw.println();
      }
      static void p(Object o)
      {
          pw.print(o+" ");
      }
      static void pl(Object o)
      {
          pw.println(o);
      }
      static void psb(StringBuilder sb)
      {
          pw.print(sb);
      }
      static void pa(String arrayName, Object arr[])
      {
          pl(arrayName+" : ");
          for(Object o : arr)
              p(o);
          pl();
      }
      static void pa(String arrayName, int arr[])
      {
          pl(arrayName+" : ");
          for(int o : arr)
              p(o);
          pl();
      }
      static void pa(String arrayName, long arr[])
      {
          pl(arrayName+" : ");
          for(long o : arr)
              p(o);
          pl();
      }
      static void pa(String arrayName, double arr[])
      {
          pl(arrayName+" : ");
          for(double o : arr)
              p(o);
          pl();
      }
      static void pa(String arrayName, char arr[])
      {
          pl(arrayName+" : ");
          for(char o : arr)
              p(o);
          pl();
      }
  
      static void pa(String arrayName, TreeSet<Integer> set)
      {
          pl(arrayName+" : ");
          for(Object o : set)
              p(o);
          pl();
      }
  
      static void pa(String arrayName, boolean arr[])
      {
          pl(arrayName+" : ");
          for(boolean o : arr)
              p(o);
          pl();
      }
      static void pa(String listName, List list)
      {
          pl(listName+" : ");
          for(Object o : list)
              p(o);
          pl();
      }
      static void pa(String arrayName, Object[][] arr) {
          pl(arrayName+" : ");
          for(int i=0;i<arr.length;++i) {
              for(Object o : arr[i])
                  p(o);
              pl();
          }
      }
      static void pa(String arrayName, int[][] arr) {
          pl(arrayName+" : ");
          for(int i=0;i<arr.length;++i) {
              for(int o : arr[i])
                  p(o);
              pl();
          }
      }
      static void pa(String arrayName, long[][] arr) {
          pl(arrayName+" : ");
          for(int i=0;i<arr.length;++i) {
              for(long o : arr[i])
                  p(o);
              pl();
          }
      }
      static void pa(String arrayName, char[][] arr) {
          pl(arrayName+" : ");
          for(int i=0;i<arr.length;++i) {
              for(char o : arr[i])
                  p(o);
              pl();
          }
      }
      static void pa(String arrayName, double[][] arr) {
          pl(arrayName+" : ");
          for(int i=0;i<arr.length;++i) {
              for(double o : arr[i])
                  p(o);
              pl();
          }
      }
      static void pa(String arrayName, boolean[][] arr) {
          pl(arrayName+" : ");
          for(int i=0;i<arr.length;++i) {
              for(boolean o : arr[i])
                  p(o);
              pl();
          }
      }
      static class MyScanner
      {
          BufferedReader br;
          StringTokenizer st;
          MyScanner(boolean readingFromFile, String suffix) throws IOException
          {
              if(readingFromFile) {
                  br = new BufferedReader(new FileReader("/Users/ddfds/Desktop/input"+suffix+".txt"));
              }
              else {
                  br = new BufferedReader(new InputStreamReader(System.in));
              }
          }
          String nextLine()throws IOException
          {
              return br.readLine();
          }
          String next() throws IOException
          {
              if(st==null || !st.hasMoreTokens())
                  st = new StringTokenizer(br.readLine());
              return st.nextToken();
          }
          int nextInt() throws IOException
          {
              return Integer.parseInt(next());
          }
          long nextLong() throws IOException
          {
              return Long.parseLong(next());
          }
          double nextDouble() throws IOException
          {
              return Double.parseDouble(next());
          }
      }
  }