
In the figure above, there are four shirts, using seven clothespins, forming three groups of shirts.
To hang a shirt on the clothesline, we must use two clothespins (one at each end of the shirt). On the other hand, with two shirts, we can use only three clothespins by fastening the ends of two consecutive shirts with the same clothespin. When this happens, we say that a group of shirts has been formed, and that the shirts fastened by the same clothespin belong to the same group. Being in a group is a transitive property: if shirt A belongs to the same group as shirt B, and shirt B belongs to the same group as shirt C, then shirts A and C also belong to the same group. A shirt that does not share a clothespin with any other shirt forms a group by itself.
Dilson wants to hang $$$N$$$ shirts on the clothesline and, at the same time, wants exactly $$$G$$$ groups of shirts to be formed. What is the minimum number of clothespins Dilson needs to use to achieve his goal?
The only line of input contains two integers $$$N$$$ ($$$1 \leq N \leq 10^{6}$$$) and $$$G$$$ ($$$1 \leq G \leq N$$$), the number of shirts Dilson wants to hang and the number of groups he wants to form, respectively.
The output should contain a single integer: the number of clothespins Dilson needs to use to hang $$$N$$$ shirts in $$$G$$$ groups.
4 3
7
2 1
3
Explanation for example 1
As shown in the figure, Dilson must use seven clothespins to form three groups.
Explanation for example 2
Dilson must use three clothespins: one at one end of the first shirt, one fastening the other end of the first shirt and one end of the second shirt, and one at the other end of the second shirt. Thus, the two shirts are fastened by the same clothespin, forming a group of shirts.
| Название |
|---|


