#include #include #include using namespace std; using ll = long long; int main() { int a, b, c; cin >> a >> b >> c; int num = abs(a - c); if (max(a, c) - num < b) num = b - min(a, c) - 1; if ((a > b > c) || (a < b < c)) cout << "0" << endl; else cout << num << endl; return 0; }