P4963 Miying’s Paints
Background
After Chunhui went to the United States to study abroad, Miying often felt lonely. To ease her loneliness, she always has special requirements for paints when she draws.

Description
Miying has $n$ different kinds of paints, numbered from $1$ to $n$. Each kind of paint can be used at most once. When she starts a painting, she may choose any one paint to use.
After that, each time Miying chooses a paint $i$ to use such that, after using paint $i$, the $gcd$ (greatest common divisor) of the indices of all paints used so far is as large as possible, that is:
> Let the set of indices of paints already used be $A$. If $\ \exists\ i,\ j\notin A,\ i,\ j\in [1,\ n],\ gcd(A,\ i)>gcd(A,\ j)$, then paint $j$ cannot be chosen.
If there are multiple paints that satisfy the condition, Miying may choose any one of them. After each paint is used, Miying gains a happiness value equal to the $gcd$ of the indices of all paints used so far.
Now Miying wants to draw a painting using $m$ kinds of paints. What is the maximum possible sum of happiness values she can obtain?
Input Format
A single line with two positive integers $n,\ m$, representing the number of kinds of paints and the number of paints Miying will use.
Output Format
Output one positive integer, the maximum happiness value Miying can obtain.
Explanation/Hint
$1\le m\le n\le 10^7$.
# Constraints
# Sample Explanation
Sample 1: `6 3 5 2` is an optimal solution. The happiness values obtained each time are `6 3 1 1`.
Sample 2: `15 10 5` is an optimal solution. The happiness values obtained each time are `15 5 5`.
Translated by ChatGPT 5