#include using namespace std; template bool cmin(T &a, U b) { return a > b && (a = b, true); } template bool cmax(T &a, U b) { return a < b && (a = b, true); } signed main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int A, B, S; cin >> A >> B >> S; int ans = 0; if (S == 1) { ans += abs(A - S); A = S; return cout << ans + A << "\n", 0; } if (abs(A - S) <= abs(B - S)) { ans += abs(A - S); A = S; return cout << ans + A << "\n", 0; } else { ans += abs(B - S); B = S; ans += B - 1; B = 1; ans += abs(A - 1); A = 1; return cout << ans + A << "\n", 0; } }