A - Poisonous Cookies Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 200

問題文

高橋君は、解毒剤入りの美味しくないクッキーを A 枚、解毒剤入りの美味しいクッキーを B 枚、毒入りの美味しいクッキーを C 枚持っています。

高橋君は、毒入りのクッキーを食べるとお腹を壊し、お腹を壊した状態で毒入りのクッキーを食べると死んでしまいます。 高橋君は死にたくないので、お腹を壊した状態で毒入りのクッキーを食べることはできません。 お腹を壊した状態で解毒剤入りのクッキーを食べると、お腹の調子が治ります。 解毒剤入りのクッキーを食べる以外に、お腹の調子を治す方法はありません。

高橋君が食べることのできる美味しいクッキーの枚数の最大値を求めてください。

制約

  • 0 \leq A,B,C \leq 10^9
  • A,B,C は整数である

入力

入力は以下の形式で標準入力から与えられる。

A B C

出力

高橋君が食べることのできる美味しいクッキーの枚数の最大値を出力せよ。


入力例 1

3 1 4

出力例 1

5

以下のような順番でクッキーを食べることで、美味しいクッキーをすべて食べることができます。

  • 毒入りの美味しいクッキー
  • 解毒剤入りの美味しくないクッキー
  • 毒入りの美味しいクッキー
  • 解毒剤入りの美味しいクッキー
  • 毒入りの美味しいクッキー
  • 解毒剤入りの美味しくないクッキー
  • 毒入りの美味しいクッキー

入力例 2

5 2 9

出力例 2

10

入力例 3

8 8 1

出力例 3

9

Score : 200 points

Problem Statement

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.


Sample Input 1

3 1 4

Sample Output 1

5

We can eat all tasty cookies, in the following order:

  • A tasty cookie containing poison
  • An untasty cookie containing antidotes
  • A tasty cookie containing poison
  • A tasty cookie containing antidotes
  • A tasty cookie containing poison
  • An untasty cookie containing antidotes
  • A tasty cookie containing poison

Sample Input 2

5 2 9

Sample Output 2

10

Sample Input 3

8 8 1

Sample Output 3

9