시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB138595050.000%

문제

ICPC Square is a hotel provided by the ICPC Committee for the accommodation of the participants. It consists of $N$ floors (numbered from $1$ to $N$). This hotel has a very unique elevator. If a person is currently at floor $x$, by riding the elevator once, they can go to floor $y$ if and only if $y$ is a multiple of $x$ and $y - x ≤ D$.

You are currently at floor $S$. You want to go to the highest possible floor by riding the elevator zero or more times. Determine the highest floor you can reach.

입력

A single line consisting of three integers $N$ $D$ $S$ ($2 ≤ N ≤ 10^{12}$; $1 ≤ D ≤ N - 1$; $1 ≤ S ≤ N$).

출력

Output a single integer representing the highest floor you can reach by riding the elevator zero or more times.

예제 입력 1

64 35 3

예제 출력 1

60

First, ride the elevator from floor $3$ to floor $15$. This is possible because $15$ is a multiple of $3$ and $15 - 3 ≤ 35$. Then, ride the elevator from floor $15$ to floor $30$. This is possible because $30$ is a multiple of $15$ and $30 - 15 ≤ 35$. Finally, ride the elevator from floor $30$ to floor $60$. This is possible because $60$ is a multiple of $30$ and $60 - 30 ≤ 35$.

예제 입력 2

2024 2023 1273

예제 출력 2

1273