410383: GYM104015 A Candies

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

Description

A. Candiestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Monocarp works as a principal in a school. He has $$$n$$$ candies and he wants to gift some of them to his students. There are $$$a$$$ boys and $$$b$$$ girls in the school.

Monocarp has decided that he'll gift some positive number of candies to each boy (the same number of candies for each boy) and some positive number of candies to each girl (the same number of candies for each girl). Moreover, the number of candies he gifts to each boy should be strictly less than the number of candies he gifts to each girl.

Monocarp wants to gift as many of his $$$n$$$ candies as possible. Your task is to calculate the minimum possible number of candies that are not gifted to anyone, if you can decide how many candies each boy will receive and how many candies each girl will receive.

You may assume that the input data meets the following constraints: it is possible to give at least one candy to each boy and at least two candies to each girl (in other words, $$$a + 2 \cdot b \le n$$$).

Input

The first line contains three integers $$$n$$$, $$$a$$$ and $$$b$$$ ($$$3 \le n \le 1\,000$$$, $$$1 \le a, b \le 100$$$, $$$a + b \cdot 2 \le n$$$) — the number of candies Monocarp has, the number of boys and the number of girls, respectively.

Output

Print the minimum possible number of candies that are not gifted to anyone, if you can decide how many candies will receive each boy and how many candies will receive each girl.

ExamplesInput
34 5 6
Output
0
Input
42 4 7
Output
2
Note

In the first example, Monocarp can give $$$2$$$ candies to every boy and $$$4$$$ candies to every girl, so he'll gift all his candies.

In the second example, Monocarp can give $$$3$$$ candies to every boy and $$$4$$$ candies to every girl. Then he'll gift $$$3 \cdot 4 + 4 \cdot 7 = 40$$$ candies in total, and $$$2$$$ candies will remain.

加入题单

上一题 下一题 算法标签: