No.415 Pyon
Problem Statement
$N$ platforms are arranged on a circular ring at equal intervals of distance $1$. Starting from a certain platform, the platforms are numbered from $1$ to $N$ in order.
Usagi-chan suddenly felt like going "pyon" (hopping).
Currently, Usagi-chan is on platform $1$. With $1$ pyon, Usagi-chan can glide along the ring and move only to a platform at distance $D$ away.
Usagi-chan can repeat pyon any number of times, but the platforms are delicate, so once Usagi-chan does a pyon, the platform Usagi-chan was originally on disappears.
Find the maximum number of times Usagi-chan can pyon.
Input
$N$ $D$
The number of platforms $N(1 \le N \le 2 \times 10^9)$ and the pyon distance $D(1 \le D \le N)$ are given on $1$ line.
Output
Output the maximum number of times Usagi-chan can pyon on $1$ line.
Print a newline at the end.
Sample
Sample 1
Input
4 2
Output
1
It is only possible to move from platform $1$ to platform $3$.
Sample 2
Input
5 2
Output
4
For example, Usagi-chan moves as follows.
- Platform $1$ -> Platform $3$ -> Platform $5$ -> Platform $2$ -> Platform $4$
Sample 3
Input
114 114
Output
0
Note that there are cases where Usagi-chan cannot move even once.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
ei1333333
37zigen