AtCoder Regular Contest 137
A
Coprime Pair
AtCoder
⌀ 480
原题
←B →
翻译中…

Problem Statement

翻译中…

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

翻译中…

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

翻译中…
  • $L \leq x < y \leq R$
  • $\gcd(x,y)=1$
翻译中…

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

翻译中…

Constraints

翻译中…
  • $1 \leq L < R \leq 10^{18}$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

L R

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
2 4
Output #1
1
For $(x,y)=(2,4)$, we have $\gcd(x,y)=2$, which violates the condition. For $(x,y)=(2,3)$, the conditions are satisfied. Here, the value of $(y-x)$ is $1$. There is no such pair with a greater value of $(y-x)$, so the answer is $1$.
Input #2
14 21
Output #2
5
Input #3
1 100
Output #3
99
题目信息
题号
arc137_a
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。