#P965C. Greedy Arkady
Greedy Arkady
Description
people want to split candies between them. Each candy should be given to exactly one of them or be thrown away.
The people are numbered from to , and Arkady is the first of them. To split the candies, Arkady will choose an integer and then give the first candies to himself, the next candies to the second person, the next candies to the third person and so on in a cycle. The leftover (the remainder that is not divisible by ) will be thrown away.
Arkady can't choose greater than as it is considered greedy. Also, he can't choose such a small that some person will receive candies more than times, as it is considered a slow splitting.
Please find what is the maximum number of candies Arkady can receive by choosing some valid .
The only line contains four integers , , and (, , , , ) — the number of candies, the number of people, the maximum number of candies given to a person at once, the maximum number of times a person can receive candies.
Print a single integer — the maximum possible number of candies Arkady can give to himself.
Note that it is always possible to choose some valid .
Input
The only line contains four integers , , and (, , , , ) — the number of candies, the number of people, the maximum number of candies given to a person at once, the maximum number of times a person can receive candies.
Output
Print a single integer — the maximum possible number of candies Arkady can give to himself.
Note that it is always possible to choose some valid .
Samples
Note
In the first example Arkady should choose . He will give candies to himself, candies to the second person, candies to the third person, then candies to the fourth person and then again candies to himself. No person is given candies more than times, and Arkady receives candies in total.
Note that if Arkady chooses , he will receive only candies, and if he chooses , he will receive only candies as well as the second person, the third and the fourth persons will receive candies, and candies will be thrown away. He can't choose nor because in these cases he will receive candies more than times.
In the second example Arkady has to choose , because any smaller value leads to him receiving candies more than time.