407001: GYM102672 I Tennis score

Memory Limit:512 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

I. Tennis scoretime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

Aurora and Knotgrass decided to play tennis and asked Thistlelwit to be the judge. At the start the score was $$$0 : 0$$$. Then, a few times the score increased by $$$1$$$. The game ended with the score $$$a : b$$$.

Thistlelwit was bored so she counted the sum of the gcds of the players' scores after each score change. the gcd  — is the greatest divisor of two numbers. For example, the game could go as follows:

  • $$$0 : 0$$$
  • $$$1 : 0$$$, $$$\textrm{gcd}(1, 0) = 1$$$
  • $$$2 : 0$$$, $$$\textrm{gcd}(2, 0) = 2$$$
  • $$$2 : 1$$$, $$$\textrm{gcd}(2, 1) = 1$$$
  • $$$2 : 2$$$, $$$\textrm{gcd}(2, 2) = 2$$$
  • $$$2 : 3$$$, $$$\textrm{gcd}(2, 3) = 1$$$

In that case, Thistlelwit would get $$$1 + 2 + 1 + 2 + 1 = 7$$$.

After the end of the game Thistlelwit got curious about what minimal number she could potentially get. Please, help her calculate that number.

Input

The first line contains two integers $$$a$$$ and $$$b$$$ — the final scores of Aurora and Knotgrass ($$$0 \le a, b \le 10^9$$$).

Output

Output one number  — the minimal score which Thistlelwit could get.

ExamplesInput
2 1
Output
3
Input
4 6
Output
11
Input
0 0
Output
0
Input
10 10
Output
31

加入题单

算法标签: