#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 cout << min(abs(A - B) + abs(A - S) + S, B - 1 + A - 1 + 1) << endl; }