#include #include #include #include using namespace std; int main(int argc, char *argv[]) { int A, B, S; string s; getline(cin, s); stringstream ss(s); ss >> A >> B >> S; int ans = 0; int a = abs(A - S), b = abs(B - S); if (a <= b || S <= 1) { ans = a + S; } else { ans = b; if (A < B) { ans += b; } else if (A < B * 2) { ans += A - b + A; } else { ans += b - 1 + A; } } cout << ans << endl; return 0; }