atcoder#ARC137A. [ARC137A] Coprime Pair

[ARC137A] Coprime Pair

Score : 300300 points

Problem Statement

You are given integers L,RL,R (L<RL < R).

Snuke is looking for a pair of integers (x,y)(x,y) that satisfy both of the conditions below.

  • Lx<yRL \leq x < y \leq R
  • gcd(x,y)=1\gcd(x,y)=1

Find the maximum possible value of (yx)(y-x) in a pair that satisfies the conditions. It can be proved that at least one such pair exists under the Constraints.

Constraints

  • 1L<R10181 \leq L < R \leq 10^{18}
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

LL RR

Output

Print the answer.

2 4
1

For (x,y)=(2,4)(x,y)=(2,4), we have gcd(x,y)=2\gcd(x,y)=2, which violates the condition. For (x,y)=(2,3)(x,y)=(2,3), the conditions are satisfied. Here, the value of (yx)(y-x) is 11. There is no such pair with a greater value of (yx)(y-x), so the answer is 11.

14 21
5
1 100
99