cd

A poor man had p cats and c dogs, which he took with him from place to place. One day he arrived at a deep river, which not even the bravest dog would have swum. On the bank of the river our man found a boat, but unfortunately it only fit k animals.
So our man decided to cross the river several times, until all the animals arrive to the other side.
The problem is not so simple because, due to a legendary happening, if the animals remain unattended on a bank and the number of dogs is larger than the number of cats, the dogs will lethally attack the cats.

Task

Write a program that determines the minimum number of crossings our man has to make in order to transport all the animals safely to the other bank.

Input Data

Input file cd.in contains a single line with three positive integers separated by a space, p c k, with the meaning from the task.

Output Data

Output file cd.out will contain a single line with the minimum number of crossings necessary.

Restrictions and Mentions

Examples
cd.in cd.out Explanation

5 7 3

9

A solution with a minimum number of crossings can be:

crosses from bank 1 to bank 2 with 3 dogs (4 dogs and 5 cats are left on bank 1)
crosses from bank 2 to bank 1 with an empty boat
crosses from bank 1 to bank 2 with two cats and a dog (on bank 1 3 cats and 3 dogs stay behind)
crosses from bank 2 to bank 1 with 2 dogs
crosses from bank 1 to bank 2 with 3 cats (on bank 1 5 dogs stay behind)
crosses from bank 2 to bank 1
crosses from bank 1 to bank 2 with 3 dogs (on bank 1 2 dogs stay behind)
crosses from bank 2 to bank 1
crosses from bank 1 to bank 2 with 2 dogs

Time limit: 0.4 seconds/test

prof. Emanuela Cerchez
"Grigore Moisil" Iaşi IT High School
Contact:emanuela.cerchez@gmail.com