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 T. Eating one orange raises her fullness by A, and eating one lemon raises it by B. She refuses any fruit that would push her fullness past T.
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.