#include using namespace std; #define ll long long ll mod =1000000007; /*"itob" int to "N"base */ template string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;} /*"chmin" a = MAX*/ template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } /*"chmax" a = MIN*/ template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } /*"ctoi" char to int*/ int ctoi(char c) {return c-'0';} /*"gcd" MAX*/ int gcd(ll a,ll b){return b?gcd(b,a%b):a;} /*"lcm" MIN*/ int lcm(ll a,ll b){return a*b/gcd(a,b);} /*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}} string reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;} int main(){ int a,b,c; cin >> a >> b >> c; if(min({a,b,c})==b){ ll ans = a-b+c-b+2; cout << ans << endl; } else { ll ans = max(a,c)-min(a,c); cout << ans << endl; } }