题目描述
Problem Description
There are $ x $ coins facing up and $ y $ coins facing down. Takahashi will choose exactly $ k $ coins and flip them all. What is the maximum number of coins that can face up as a result?
Input Format
The input is given from the standard input in the following format:
$ x $ $ y $ $ k $
- The first line contains the number of coins facing up $ x $ ($1 \leq x \leq 10^6$) and the number of coins facing down $ y $ ($1 \leq y \leq 10^6$) separated by a space.
- The second line contains the number of coins to flip $ k $ ($1 \leq k \leq x + y$).
Output Format
Output a single line containing the maximum number of coins that can face up after flipping. End the output with a newline.
Sample Input and Output
Sample Input #1
3 2
1
Sample Output #1
4
Sample Input #2
3 2
4
Sample Output #2
3
Sample Input #3
3 2
5
Sample Output #3
2
Notes/Hints
Sample Explanation 1
It is sufficient to flip one coin facing down.
Sample Explanation 2
It is sufficient to flip two coins facing up and two coins facing down.
Sample Explanation 3
All coins must be flipped.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分
样例输入
3 2
1
样例输出
4