#include #include #include using namespace std; int main(){ int A, B, S; cin >> A >> B >> S; if (abs(A - S) <= abs(B - S) || S == 1) cout << abs(A - S) + S << endl; else if (A != 0) cout << abs(B - S) + min(abs(A - S) + +A, abs(S - 1) + abs(A - 1) + 1) << endl; else cout << abs(B - S) + abs(S - 1) + abs(A - 1) + 1 << endl; }