#include #include #include #include #include #include using namespace std; int main(){ long a,b,c; cin >> a >> b >> c; long mid=max(a,c); long mi=min(a,c); long cost=min((b-mid),(mid-mi)); cout << cost << endl; return 0; }