Problem E
Cousins
Languages
en
pt
Tom, Dick and Harry are cousins. Harry is learning number theory, so he is constantly asking his older cousins to give him problems.
Tom and Dick came up with a simple problem to distract Harry. Harry receives a number $n$ from Tom and $m$ from Dick. Harry then counts the sum of the numerators and denominators of the fractions $\frac{a}{b}$ such that $1 \le a \le n$ and $ 1 \le b \le m$.
Harry quickly said that the game was too easy for him. Tom then said that Harry couldn’t count the same fraction twice. Dick completed saying that if $ a d = b c $ then the fractions $\frac{a}{b}$ and $\frac{c}{d}$ are equal and Harry should only take into account the one with smallest numerator.
Since the cousins did not want to help Harry after he underestimated the problem, he came to you for help.
Input
The only input line contains two integers $n$ and $m$ ($ 1 \le n \le 10^6$, and $1 \le m \le 10^6$), the numbers described above.
Output
You should print a single line containing the answer to the problem described by Tom and Dick.
Sample Input 1 | Sample Output 1 |
---|---|
1 1 |
2 |
Sample Input 2 | Sample Output 2 |
---|---|
1 3 |
9 |
Sample Input 3 | Sample Output 3 |
---|---|
5 10 |
283 |