407440: GYM102791 F Deposit

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

F. Deposittime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Monocarp saved up $$$n$$$ burles and decided to deposit all his $$$n$$$ burles in a local bank.

Unfortunately, Monokarp hasn't read the license agreement, that's why now he has only two types of operations with money in the deposit (fortunately, he can make any number of operations of each type):

  • withdraw $$$a$$$ burles from the bank account (he can make this operation only if he stores at least $$$a$$$ burles using his bank account);
  • deposit $$$b$$$ burles to the account (he can make this operation only if he has $$$b$$$ burles in his possession).

Assume that Monocarp put all his $$$n$$$ burles in the bank account and he has no more money left, so he can work only with money he put in the bank.

Calculate the maximum possible amount of burles Monocarp can obtain from his bank account using only described operations.

Input

The first line contains three integers $$$n$$$, $$$a$$$, and $$$b$$$ ($$$1 \le a, b \le n \le 10^{6}$$$) — the number of burles Monocarp deposited initially, the number of burles he can withdraw from the account in one operation, and the number of burles he can deposit to the account in one operation.

Output

Print the maximum possible amount of burles Monocarp can obtain from his bank account using only operations described in the statement.

ExamplesInput
17 5 3
Output
17
Input
97 10 6
Output
96
Input
77141 21540 3108
Output
77136

加入题单

上一题 下一题 算法标签: