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: // package com.company;
  
  
  
  import com.sun.source.tree.Tree;
  
  import java.util.*;
  import java.io.*;
  
  public class Main {
  
       static TreeMap<Integer,Integer> mp = new TreeMap<>();
       static int fac[] = new int[200000];
      public static int totalSum(int n) {
  
          // Stores total sum
          int result = 0;
          int i = 1;
  
          // Finding numbers and
          //its occurence
          while(true) {
  
              // Sum of product of each
              // number and its occurence
             // result += rangeSum(n / i, n / (i + 1)) *
           //           (i % mod) % mod;
              mp.put(i,n/i - n/(i+1));
  
              //result %= mod;
  
              if (i == n)
                  break;
  
              i = n / (n / (i + 1));
          }
          return result;
      }
  
  
  
      public static void main(String[] args) throws Exception {
          long start=System.currentTimeMillis();
          FastScanner fs=new FastScanner();
          int T=1; // T=fs.nextInt();
          while(T--!=0) {
              int n=fs.nextInt(),m=fs.nextInt();
              int dp[] = new int[n+1];
              int pdp [] = new int[n+2];
              dp[n] = 1;
              pdp[n]=1;
              int sum_till_now=1;
              for(int i=n-1;i>=1;i--){
                  dp[i] = (dp[i] + sum_till_now)%m;
                  // do stuff for j = 1
                  for(int j=2;i*j<=n;j++){
                      int extra_add = pdp[i*j] - pdp[Math.min(n+1,i*j + j)];
                      if(extra_add < 0) extra_add =(int) ((long)extra_add+(long)m)%m;
  //                    if(i*j + 1 <=n ) extra_add = pdp[i*j] - pdp[i*j + Math.min(i,j)];    //dp[i*j +1];
                      dp[i] =(int) ((long)dp[i]  + (long)extra_add) % m;
                  }
                //  dp[i]  = (dp[i] + pdp[i+1] - pdp[Math.min(2*i,n)]);
                 // System.out.println(i + " "+ sum_till_now);
                  sum_till_now =(int) ((long)sum_till_now + (long)dp[i])%m;
                  pdp[i] = sum_till_now;
  
              }
             // for(int i=1;i<=n;i++) System.out.print(dp[i]+ " ");
             // System.out.println();
              System.out.println((dp[1])%m);
  
  //            int mx = 1000000009;
  //            short count[] = new short[mx];
  //            for(int i=0;i<mx;i++){
  //                count[i]=2;
  //            }
  //
  //            for(int i=2;i<mx;i++){
  //              //  if(count[i]==2) {
  //                    for (int j = 2; i * j < mx; j++){
  //                       count[i*j]++;
  //                    }
  //               // }
  //            }
  //           // for(int i=0;i<100;i++) System.out.println(Integer.toString(i)+" "+Integer.toString(count[i]));
  //            int freq[] = new int[100000];
  //            for(int i=0;i<100000;i++) freq[i]=0;
  //            for(var v : count) freq[v]++;
  //
  //            for(int i=0;i<100000;i++) System.out.println(Integer.toString(i)+",");
  //            mp.clear();
  //            int n=fs.nextInt(),m=fs.nextInt();
  //            totalSum(n);
  //            long ans=0;
  //            long mod = 1000000007;
  //            for(var v : mp.keySet()){
  //                ans += v * mp.get(v) * binexp(v,)
  //            }
  
          }
  //         long end=(System.currentTimeMillis()-start);
  //         System.err.println("Time taken is "+end+" ms");
      }
  
      void factorial(int k,int md)
      {
  
          fac[0] = 1;
          for (int i = 1; i <= k + 1; i++) {
              fac[i] = (i * fac[i - 1])%md;
          }
      }
  
  // Function to return the binomial coefficient
      static long bin(int a, int b,int md)
      {
  
          // nCr = (n! * (n - r)!) / r!
          long num = fac[a];
          long den = (fac[a-b] * fac[b]) %md;
  
         // long  ans =
         //     ((fac[a]) / (fac[a - b] * fac[b]));
          long ans = num * binexp(den,md-2,md);
          return ans;
      }
  
  // Function to return the sum of kth powers of
  // n natural numbers
      static long sumofn(int n, int k,int md)
      {
          int p = 0;
          long  num1, temp, arr[] = new long[2000];
          for (int j = 1; j <= k; j++) {
  
              // When j is unity
              if (j == 1) {
                  num1 = ((n * (n + 1)) / 2)%md;
  
                  // Calculating sum(n^1) of unity powers
                  // of n; storing sum(n^1) for sum(n^2)
                  arr[p++] = num1;
  
                  // If k = 1 then temp is the result
                  temp = num1;
              }
              else {
                  temp = (binexp(n + 1, j + 1,md) - 1 - n);//(pow(n + 1, j + 1) - 1 - n);
                  if(temp<0){
                      temp=temp+md;
                      temp%=md;
                  }
                  // For finding sum(n^k) removing 1 and
                  // n * kCk from (n + 1)^k
                  for (int s = 1; s < j; s++) {
  
                      // Removing all kC2 * sum(n^(k - 2))
                      // + ... + kCk - 1 * (sum(n^(k - (k - 1))
                      temp = temp -
                              (arr[j - s - 1] * bin(j + 1, s + 1,md));
                      if(temp<0){
                          temp=temp+md;
                          temp%=md;
                      }
                  }
                  temp = temp / (j + 1);
  
                  // Storing the result for next sum of
                  // next powers of k
                  arr[p++] = temp;
              }
          }
          temp = arr[p - 1];
          return temp;
      }
  
  
      public static long binexp(long a, long b,long md){
          if(b==0) return 1;
          if(b==1) return a%md;
          long xx=binexp(a,b/2,md);
          if(b%2==0){
              return (xx%md * xx%md)%md;
          }
          else {
              return (xx%md * xx%md * a)%md;
          }
      }
  
  
      public static int gcd(int a,int b) {
          if (b == 0) return a;
          if (a == 0) return b;
          if (a > b) return gcd(b, a);
          return gcd(a, b % a);
  
      }
  
  
      @Override
      protected Object clone() throws CloneNotSupportedException {
          return super.clone();
      }
  
      static void sort(int[] a) {
          ArrayList<Integer> l=new ArrayList<>();
          for (int i:a) l.add(i);
          Collections.sort(l);
          for (int i=0; i<a.length; i++) a[i]=l.get(i);
      }
  
  
      static class FastScanner {
          BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
          StringTokenizer st=new StringTokenizer("");
          String next() {
              while (!st.hasMoreTokens())
                  try {
                      st=new StringTokenizer(br.readLine());
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              return st.nextToken();
          }
  
          int nextInt() {
              return Integer.parseInt(next());
          }
  
          double nextDouble() { return Double.parseDouble(next()); }
  
          int[] readArray(int n) {
              int[] a=new int[n];
              for (int i=0; i<n; i++) a[i]=nextInt();
              return a;
          }
          long nextLong() {
              return Long.parseLong(next());
          }
  
      }
      static class pair<t1 extends Comparable<t1>, t2 extends Comparable<t2> > implements Comparable<pair<t1,t2>>{
          public t1 ff;
          public t2 ss;
          pair(){}
          pair(t1 first,t2 second){
              this.ff=first;
              this.ss=second;
          }
  
          @Override
          public boolean equals(Object obj) {
              if(obj==null) return false;
              else if(obj.getClass()!=this.getClass()) return false;
              pair<?,?> pp = (pair<?,?>) obj;
              return pp.ff.equals(this.ff) && pp.ss.equals(this.ss);
          }
  
          @Override
          public int hashCode() {
              return Objects.hash(ff,ss);
              //return 31 * ff.hashCode() + ss.hashCode();
          }
  
          @Override
          public int compareTo(pair<t1,t2> pp) {
              pair<?,?> p = (pair<?,?>) pp;
              var res = this.ff.compareTo(pp.ff);
              if(res==0) res=this.ss.compareTo(pp.ss);
  
              return res;
          }
      }
  }