Fruit Feast

Eat unlimited fruits that add A or B without passing T, using at most one halving, to reach the largest fullness.

Medium5Dynamic programmingInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

Bessie has broken into Farmer John's house again. In the kitchen she found a pile of lemons and a pile of oranges, and there are so many of each that you can treat the supply as unlimited. She plans to eat as much as she can.

Bessie's fullness can never go above TT. Eating one orange raises her fullness by AA, and eating one lemon raises it by BB. She refuses any fruit that would push her fullness past TT.

Bessie can also drink water at most one time. Drinking water immediately cuts her fullness in half, rounded down.

Find the largest fullness Bessie can reach.

Input

The first and only line contains three integers TT, AA, and BB, separated by spaces. (1T50000001 \le T \le 5\,000\,000, 1A,BT1 \le A, B \le T)

Output

Print the largest fullness Bessie can reach, on one line.