#include #include #include #include #include #include #include #include #include #include #include #include #include #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() using namespace std; typedef long long ll; typedef pair pi; typedef pair pl; typedef pair pls; int main() { ll A, B, S; cin >> A >> B >> S; ll ans = 0; if (S <= A ||((A == B) && A > S)) { ans = A; } else if (B > S && S > A) { ans = min(B,((S - A) * 2)+A); if (A == 0)ans++; } else if (S > A && A >= B) { ans = (S - A) + S; if (A == 0)ans++; } else if (S > B && B > A) { ans = 2 * S - B; if (A == 0)ans++; } else if (S == B && S > A) { ans = (S-A)*2 + A; } cout << ans << endl; return 0; }