#define NOMINMAX #define TEST_MODE true #define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include "bits/stdc++.h" #include using namespace std; #define rep(i,n) for(int i=0;i<(int)(n);++i) #define rep2(i,a,n) for(int i=a;i<(int)(n);++i) #define rrep(i,n) for(int i=(n)-1;i>=0;--i) #define reu(i,n) for(int i=1;i<=(int)(n);++i) #define chmax(a,b) (a=(a)<(b)?(b):(a)) #define chmin(a,b) (a=(a)>(b)?(b):(a)) using ll = long long; #define all(a) begin(a),end(a) #define int long long #ifdef LOCAL_ENV #define dump(x) cerr<<#x<<" : "<<(x)<< " \t" #define dumpl(x) dump(x)<void ce_vector(vector a) { #ifdef LOCAL_ENV rep(i, a.size() - 1) cerr << a[i] << " "; cerr << a[a.size() - 1] << endl; #endif } templatevoid ce_vector(vector> a) { #ifdef LOCAL_ENV rep(i, a.size()) cerr << a[i].first << "," << a[i].second << " "; cerr << endl; #endif } templatevoid co_vector(vector a) { rep(i, a.size() - 1) cout << a[i] << " "; cout << a[a.size() - 1] << endl; } templatevoid co_vector(vector> a) { rep(i, a.size()) cout << a[i].first << "," << a[i].second << " "; cout << endl; } ll pow_n(ll x, ll n) { ll r = 1; while (n > 0) { if (n & 1)r = (r * x) % mod_n; x = (x * x) % mod_n; n >>= 1; }return r; } template vector in_vec(int n) { vector a(n); a.resize(n); rep(i, n) cin >> a[i]; return a; } int div_ceil(int a, int b) { int r = a / b; if (a % b != 0)r++; return r; } ll modular(ll x) { return ((x % mod_n + mod_n) % mod_n); } // end of template void solve() { int a, b, c; cin >> a >> b >> c; int d = max(a, c) - min(a, c); dumpl(d); if (b > a and b > c) { chmin(d, b - max(a, c) + 1); } else if (b < a and b < c) { chmin(d, min(a, c) - b + 1); } cout << d << endl; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20); solve(); #ifdef LOCAL_ENV cout << endl; cerr << endl <<"\x1b[7m ↓ \x1b[0m" << endl; system("type out.txt"); #endif return 0; }