#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, a >= 1 ? abs( b - s ) + abs( s - a ) + a : 0x3f3f3f3f ); cout << ans << endl; } return 0; }