#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{ cout << abs( b - s ) + abs( a - s ) + a << endl; } return 0; }