#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef vector vi; typedef vector vvi; typedef pair pii; #define all(c) (c).begin(), (c).end() #define loop(i,a,b) for(ll i=a; iDUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this< ostream& operator<<(ostream& os, vector const& v){ rep(i,v.size()) os << v[i] << (i+1==v.size()?"":" "); return os; } int const inf = 1<<26; int main(){ int A,B,S; while(cin>>A>>B>>S){ int ans; if(S!=1){ if(abs(S-A) > abs(S-B)) throw ""; int t1 = abs(S-A) > abs(S-B) ? abs(B-S)+abs(S-1)+A : inf; // S-b>1-a>0 int t2 = abs(S-A) <= abs(S-B) ? abs(A-S)+S : inf; // S-a>0 int t3 = abs(S-A) > abs(S-B) ? abs(S-B)+abs(B-A)+A : inf; // S-b>A-a>0 dump(t1,t2,t3); ans = min({t1,t2,t3}); } else { ans = abs(S-A) + 1; } cout << ans << endl; } }