Contest Duration: - (local time) (300 minutes) Back to Home
A - Trafic Light /

Time Limit: 2 sec / Memory Limit: 1024 MB

### 問題文

ボタン付きの信号機があります。
この信号機は、信号が赤の時にボタンを押すと原則的には X 秒後に青に変わります。
ただし、最後に赤に変わってから Y 秒経つよりも早く青に変わってしまう場合は、代わりに最後に赤に変わってから Y 秒経った瞬間に青に変わります。

### 制約

• 1 \leq X,Y,Z \leq 100
• 入力される値はすべて整数

### 入力

X Y Z


### 入力例 1

10 20 5


### 出力例 1

20


### 入力例 2

10 20 15


### 出力例 2

25


### 入力例 3

36 49 73


### 出力例 3

109


Score : 9 points

### Problem Statement

There is a traffic light with a button.
In principle, if you press the button when the light is red, it turns green X seconds later.
However, if it would turn green earlier than Y seconds after it turned red last time, it turns green Y seconds after it turned red last time instead.

Now, the button has just been pressed Z seconds after it turned red last time.
How many seconds will pass before it turns green since it turned red last time?

### Constraints

• 1 \leq X,Y,Z \leq 100
• All values in input are integers.

### Input

Input is given from Standard Input in the following format:

X Y Z


### Output

Print the answer as an integer.

### Sample Input 1

10 20 5


### Sample Output 1

20


The elapsed time Z since it turned red plus X equals 5 + 10 = 15 seconds, which is less than Y = 20 seconds. So, as mentioned in the Problem Statement, it will turn green 20 seconds after it turned red.

### Sample Input 2

10 20 15


### Sample Output 2

25


### Sample Input 3

36 49 73


### Sample Output 3

109