#include using namespace std; signed main(){ int a, b, s; cin >> a >> b >> s; if( abs( a - s ) <= abs( b - s ) or s == 1 ){ cout << abs( a - s ) + s << endl; } else{ int ans = min( abs( b - s ) + abs( s - 1 ) + abs( a - 1 ) + 1, abs( b - s ) + abs( s - a ) + a ); cout << ans << endl; } return 0; }