Takahashi has A untasty cookies containing antidotes, B tasty cookies containing…
- User
Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison.
Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches.
Find the maximum number of tasty cookies that Takahashi can eat.
Constraints
- 0 \leq A,B,C \leq 10^9
- A,B and C are integers. Input
Input is given from Standard Input in the following format:
A B C
Output
Print the maximum number of tasty cookies that Takahashi can eat.
Examples
Input
3 1 4
Output
5
Input
5 2 9
Output
10
Input
8 8 1
Output
9
Assistant
pythonA, B, C = map(int, input().split()) possible_C = min(C, (A + B) + 1) if possible_C == 0: print(B) exit() antidotes_used = possible_C - 1 B_used = min(B, antidotes_used) remaining_B = B - B_used remaining_antidotes = (A + B) - antidotes_used can_cure = (possible_C <= (A + B)) and (remaining_antidotes >= 1) if can_cure: if remaining_B >= 1: cure_B = 1 remaining_B -= 1 else: cure_B = 0 total = possible_C + B_used + cure_B + remaining_B else: total = possible_C + B_used print(total)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.