#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 = 0; for( int i = 1; i <= s; ++i ) ans = min( ans, abs( b - s ) + abs( s - i ) + abs( a - i ) + i ); cout << ans << endl; } return 0; }